Create user

This commit is contained in:
Hugo Falcao
2022-04-17 20:32:51 -03:00
commit 60dc95bac8
80 changed files with 10187 additions and 0 deletions

39
src/server.ts Normal file
View File

@@ -0,0 +1,39 @@
import 'reflect-metadata';
import express, { Request, Response, NextFunction } from 'express';
import 'express-async-errors';
import { createConnection } from "typeorm";
import routes from './routes';
import AppError from './errors/AppError';
import cors from "cors";
const app = express();
app.use(cors());
app.use(express.json());
app.use(routes);
createConnection();
app.use((err: Error, request: Request, response: Response, _: NextFunction) => {
if (err instanceof AppError) {
return response.status(err.statusCode).json({
status: 'error',
message: err.message,
});
}
console.error(err);
return response.status(500).json({
status: 'error',
message: 'Internal server error',
});
});
app.listen(3333, () => {
console.log('🚀 Server started on port 3333!');
});