Merge pull request #617 from spotify/freben/backend

Initial skeleton for the backend
This commit is contained in:
Fredrik Adelöw
2020-04-22 19:41:58 +02:00
committed by GitHub
7 changed files with 319 additions and 9 deletions
+6
View File
@@ -0,0 +1,6 @@
module.exports = {
rules: {
'no-console': 0, // Permitted in console programs
'new-cap': ['error', { capIsNew: false }], // Because Express constructs things e.g. like 'const r = express.Router()'
},
};
+34
View File
@@ -0,0 +1,34 @@
{
"name": "example-backend",
"version": "0.1.1-alpha.4",
"main": "dist",
"private": true,
"license": "Apache-2.0",
"engines": {
"node": ">=12"
},
"scripts": {
"build": "tsc",
"start": "tsc-watch --onFirstSuccess nodemon",
"lint": "backstage-cli lint",
"test": "backstage-cli test",
"clean": "backstage-cli clean"
},
"dependencies": {
"cors": "^2.8.5",
"express": "^4.17.1",
"helmet": "^3.22.0"
},
"devDependencies": {
"@backstage/cli": "^0.1.1-alpha.4",
"@types/cors": "^2.8.6",
"@types/express": "^4.17.6",
"@types/express-serve-static-core": "^4.17.5",
"@types/helmet": "^0.0.45",
"tsc-watch": "^4.2.3",
"typescript": "^3.8.3"
},
"nodemonConfig": {
"watch": "./dist"
}
}
+21
View File
@@ -0,0 +1,21 @@
/*
* Copyright 2020 Spotify AB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
describe('test', () => {
it('unbreaks the test runner', () => {
expect(true).toBeTruthy();
});
});
+32
View File
@@ -0,0 +1,32 @@
/*
* Copyright 2020 Spotify AB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import express from 'express';
import cors from 'cors';
import helmet from 'helmet';
import { testRouter } from './test';
const PORT = 7000;
const app = express();
app.use(helmet());
app.use(cors());
app.use(express.json());
app.use('/test', testRouter);
app.listen(PORT, () => {
console.log(`Listening on port ${PORT}`);
});
+23
View File
@@ -0,0 +1,23 @@
/*
* Copyright 2020 Spotify AB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Router } from 'express';
export const testRouter = Router();
testRouter.get('/', async (_, res) => {
res.status(200).send('hello');
});
+13
View File
@@ -0,0 +1,13 @@
{
"include": ["src"],
"compilerOptions": {
"baseUrl": "src",
"outDir": "dist",
"incremental": true,
"sourceMap": true,
"strict": true,
"target": "es5",
"module": "commonjs",
"esModuleInterop": true
}
}