1- import { PrismaClient } from "@prisma/client" ;
21import express from "express" ;
32
43const PORT = process . env . PORT || 3001 ;
@@ -7,34 +6,11 @@ const app = express();
76
87app . use ( express . json ( ) ) ;
98
10- let data : any = null ;
11-
12- const prisma = new PrismaClient ( ) ;
13-
14- async function main ( ) {
15- const allUsers = await prisma . user . findMany ( ) ;
16- console . log ( "users" , allUsers ) ;
17- }
18-
19- app . post ( `/` , async ( req , res ) => {
20- data = req . body ;
21- console . log ( "server: save data=" , Object . keys ( data . diff ) ) ;
22- res . json ( { success : true } ) ;
23- } ) ;
24-
25- app . get ( `/` , async ( req , res ) => {
26- console . log ( "server: get data=" , Object . keys ( data . diff ) ) ;
27- res . json ( data ) ;
28- } ) ;
29-
30- const server = app . listen ( PORT , ( ) => {
31- main ( )
32- . catch ( ( e ) => {
33- throw e ;
34- } )
35- . finally ( async ( ) => {
36- await prisma . $disconnect ( ) ;
37- } ) ;
9+ app . use ( "/auth" , require ( "./routes/auth" ) ) ;
10+ app . use ( "/users" , require ( "./routes/users" ) ) ;
11+ app . use ( "/devices" , require ( "./routes/devices" ) ) ;
12+ app . use ( "/changes" , require ( "./routes/changes" ) ) ;
3813
14+ app . listen ( PORT , ( ) => {
3915 console . log ( `🚀 Server ready at: http://localhost:${ PORT } ` ) ;
4016} ) ;
0 commit comments