Skip to content

Commit

Permalink
Merge pull request #9 from isdi-coders-2023/feature/projectEndpoint
Browse files Browse the repository at this point in the history
Add projects endpoint and files controller, middleware and router
  • Loading branch information
FranciscoHernandez92 authored May 7, 2024
2 parents 8282c4d + f854798 commit 305fc77
Show file tree
Hide file tree
Showing 32 changed files with 715 additions and 32 deletions.
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const config = {
'tools',
'type',
'_mock',
'file.router',
// "\\\\node_modules\\\\"
],
// Indicates which provider should be used to instrument code for coverage
Expand Down
170 changes: 168 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"@types/jest": "^29.5.12",
"@types/jsonwebtoken": "^9.0.6",
"@types/morgan": "^1.9.9",
"@types/multer": "^1.4.11",
"@types/node": "^20.12.7",
"@typescript-eslint/eslint-plugin": "^7.7.1",
"@typescript-eslint/parser": "^7.7.1",
Expand All @@ -45,6 +46,7 @@
"dependencies": {
"@prisma/client": "^5.13.0",
"bcrypt": "^5.1.1",
"cloudinary": "^2.2.0",
"cors": "^2.8.5",
"cross-env": "^7.0.3",
"debug": "^4.3.4",
Expand All @@ -54,6 +56,7 @@
"joi": "^17.12.3",
"jsonwebtoken": "^9.0.2",
"morgan": "^1.10.0",
"multer": "^1.4.5-lts.1",
"nodemon": "^3.1.0",
"prisma": "^5.13.0"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
Warnings:
- You are about to drop the column `archieve` on the `Project` table. All the data in the column will be lost.
- Added the required column `archive` to the `Project` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "Project" DROP COLUMN "archieve",
ADD COLUMN "archive" TEXT NOT NULL;
2 changes: 1 addition & 1 deletion prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ model Project {
id String @id @default(uuid())
title String
content String
archieve String
archive String
category Category
author User @relation(fields: [authorId], references: [id])
authorId String
Expand Down
15 changes: 15 additions & 0 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import { UserController } from './controllers/users.controller/users.controller.
import { UserRouter } from './routers/users.routers/user.router.js';
import createDebug from 'debug';
import { AuthMiddleware } from './middleware/auth.middleware/auth.middleware.js';
import { ProjectRepository } from './repositories/projects.repository/project.repository.js';
import { ProjectController } from './controllers/projects.controller/projects.controller.js';
import { ProjectRouter } from './routers/projects.router/project.router.js';
import { FilesMiddleware } from './middleware/files.middleware/files.middleware.js';

const debug = createDebug('FP*:app');

Expand All @@ -23,8 +27,19 @@ export const startApp = (app: Express, prisma: PrismaClient) => {

const authInterceptor = new AuthMiddleware();

const filesMiddleware = new FilesMiddleware();

const usersRepo = new UserRepository(prisma);
const usersController = new UserController(usersRepo);
const usersRouter = new UserRouter(usersController, authInterceptor);
app.use('/users', usersRouter.router);

const projectsRepo = new ProjectRepository(prisma);
const projectsController = new ProjectController(projectsRepo);
const projectsRouter = new ProjectRouter(
projectsController,
authInterceptor,
filesMiddleware
);
app.use('/projects', projectsRouter.router);
};
Loading

0 comments on commit 305fc77

Please sign in to comment.