implement base api structure with express

This commit is contained in:
Guillaume Dorce 2022-08-19 12:05:53 +02:00
parent 5aa8ca01e9
commit 46f1d97c23
8 changed files with 28 additions and 3 deletions

View File

@ -6,7 +6,8 @@
"scripts": {
"dev": "nodemon --watch src -e js,ts,json --exec 'ts-node src/index.ts'",
"build": "tsc src/index.ts",
"start": "node dist/index.js"
"start": "node dist/index.js",
"db": "prisma studio"
},
"keywords": [],
"author": "",

9
src/api/index.ts Normal file
View File

@ -0,0 +1,9 @@
import { Router } from 'express';
const router = Router();
router.get('/', (req, res) => {
res.send('Hello World!');
});
export default router;

0
src/api/post.ts Normal file
View File

0
src/api/role.ts Normal file
View File

0
src/api/user.ts Normal file
View File

0
src/db.ts Normal file
View File

View File

@ -1 +1,16 @@
console.log('Hello World2');
import express, { urlencoded, json } from 'express';
import cors from 'cors';
import api from '~api';
const port = process.env.PORT || 3000;
const app = express();
app.use(cors());
app.use(urlencoded({ extended: true }));
app.use(json());
app.use('/api', api);
app.listen(port, () => {
console.log(`Server listening on port ${port}`);
});

View File

@ -17,7 +17,7 @@
"outDir": "./dist",
"strictPropertyInitialization": false,
"paths": {
"~/*": [
"~*": [
"./src/*"
],
"~~/*": [