Merge branch 'main' of https://gitea.joaoloureiro.dev.br/admin/happy-app
This commit is contained in:
@@ -1,19 +0,0 @@
|
||||
|
||||
import { Router } from 'express';
|
||||
import multer from 'multer';
|
||||
|
||||
import OrphanagesController from './controllers/OrphanagesController';
|
||||
import UploadConfig from './config/upload';
|
||||
|
||||
const routes = Router();
|
||||
const upload = multer(UploadConfig);
|
||||
|
||||
routes.get('/users', (request, response) => {
|
||||
return response.json({message: ["João"]});
|
||||
});
|
||||
|
||||
routes.post('/orphanages', upload.array('images'), OrphanagesController.create);
|
||||
routes.get('/orphanages', OrphanagesController.getAll);
|
||||
routes.get('/orphanages/:id', OrphanagesController.getIndex);
|
||||
|
||||
export default routes;
|
||||
@@ -1,26 +0,0 @@
|
||||
import 'dotenv/config';
|
||||
import express from 'express';
|
||||
import path from 'path';
|
||||
import 'express-async-errors';
|
||||
import cors from 'cors';
|
||||
|
||||
import './database/connection';
|
||||
import errorHandler from './errors/handler';
|
||||
import routes from './routes';
|
||||
|
||||
const app = express();
|
||||
|
||||
app.use(cors());
|
||||
app.use(express.json());
|
||||
|
||||
app.use('/api', routes);
|
||||
const uploadsPath = path.join(process.cwd(), 'uploads');
|
||||
app.use('/uploads', express.static(uploadsPath));
|
||||
app.use(routes);
|
||||
app.use(errorHandler);
|
||||
|
||||
app.listen(process.env.PORT || 3101, () => {
|
||||
console.log(`Serving static files for /uploads from: ${uploadsPath}`);
|
||||
console.log('Server is running on http://localhost:' + (process.env.PORT || 3101));
|
||||
console.log('Environment:', process.env.NODE_ENV || 'development');
|
||||
});
|
||||
Reference in New Issue
Block a user