diff --git a/package.json b/package.json index 604de36..9fa5e9e 100644 --- a/package.json +++ b/package.json @@ -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": "", diff --git a/src/api/index.ts b/src/api/index.ts new file mode 100644 index 0000000..23a9b52 --- /dev/null +++ b/src/api/index.ts @@ -0,0 +1,9 @@ +import { Router } from 'express'; + +const router = Router(); + +router.get('/', (req, res) => { + res.send('Hello World!'); +}); + +export default router; diff --git a/src/api/post.ts b/src/api/post.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/api/role.ts b/src/api/role.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/api/user.ts b/src/api/user.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/db.ts b/src/db.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/index.ts b/src/index.ts index 8afab6d..905cfeb 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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}`); +}); diff --git a/tsconfig.json b/tsconfig.json index 92d9b9d..301ac6c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -17,7 +17,7 @@ "outDir": "./dist", "strictPropertyInitialization": false, "paths": { - "~/*": [ + "~*": [ "./src/*" ], "~~/*": [