diff options
Diffstat (limited to 'backend/src')
| -rw-r--r-- | backend/src/db.ts | 9 | ||||
| -rw-r--r-- | backend/src/index.ts | 20 |
2 files changed, 29 insertions, 0 deletions
diff --git a/backend/src/db.ts b/backend/src/db.ts new file mode 100644 index 0000000..032e68d --- /dev/null +++ b/backend/src/db.ts @@ -0,0 +1,9 @@ +import sqlite3 from 'sqlite3'; +import { open } from 'sqlite'; + +export const connectDB = async () => { + return open({ + filename: './database.sqlite', + driver: sqlite3.Database + }); +}; diff --git a/backend/src/index.ts b/backend/src/index.ts new file mode 100644 index 0000000..fef1977 --- /dev/null +++ b/backend/src/index.ts @@ -0,0 +1,20 @@ +import express from 'express'; +import cors from 'cors'; +import { PrismaClient } from '@prisma/client'; + +const app = express(); +const port = 5000; + +app.use(cors()); +app.use(express.json()); + +const prisma = new PrismaClient(); + +app.get('/api/users', async (req, res) => { + const users = await prisma.user.findMany(); + res.json(users); +}); + +app.listen(port, () => { + console.log(`Server listening on port ${port}`); +}); |
