gmokercom/back-end/index.ts
ange 529885d9d4
Some checks failed
/ deploy (push) Failing after 4s
FIX: back-end db connection
2024-10-22 22:47:43 +07:00

53 lines
1.2 KiB
TypeScript

import { PrismaClient } from "@prisma/client";
import cors from "cors";
import login from "./api/login";
import register from "./api/register";
const client = new PrismaClient();
const express = require("express");
const app = express();
app.use(express.json());
app.use(cors());
client.$connect();
app.post("/api/register", register);
app.post("/api/login", login);
app.listen(3000, () => {
console.log(`Server is running on port 3000`);
});
client.$disconnect();
/* function verify_token(req, res, next) {
const token = req.headers["token"];
if (token) {
jwt.verify(token, process.env.JWT_SECRET, (err, user) => {
if (err) {
res.send("ERROR")
return
}
next();
})
return;
}
res.status(404);
res.send("ERROR")
} */
/* app.use('/profile', function (req, res, next) {
const token = req.headers["authorization"];
if (token) {
jwt.verify(token, secret, (err, user) => {
if (err) {
res.send("ERROR")
return
}
req.user = user;
next();
})
return;
}
res.status(404);
res.send("ERROR")
}); */