Skip to content

Commit

Permalink
feat: express adicionado
Browse files Browse the repository at this point in the history
  • Loading branch information
rafx01 committed Jan 18, 2024
1 parent 0144342 commit 3cd3600
Show file tree
Hide file tree
Showing 6 changed files with 276 additions and 35 deletions.
9 changes: 9 additions & 0 deletions express/handlers/insertDb.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Request, Response } from "express";

export default function insertDb(req: Request, res: Response) {
try {
console.log("funcionando legal");
} catch (error) {
return res.status(500).json({ message: error });
}
}
11 changes: 11 additions & 0 deletions express/routes/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Router } from "express";
import insertDb from "../handlers/insertDb";

const router = Router();

router.get("/insertdb", insertDb);
router.get("/", (_, res) => {
return res.status(200).send({ STATUS: 200 });
});

export { router };
15 changes: 15 additions & 0 deletions express/utils/app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import express from "express";
import { router } from "../routes";
import { createServer } from "http";

const app = express();
const port = 4501;

app.use(express.json());
app.use(router);

const server = createServer(app);

server.listen(port, () => {
console.log(`Express server listening on port ${port}`);
});
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"scripts": {
"build": "remix build",
"dev": "remix dev",
"api": "nodemon --watch 'src/**/*.ts' --exec 'ts-node' express/utils/app.ts",
"start": "remix-serve build",
"typecheck": "tsc"
},
Expand All @@ -15,11 +16,15 @@
"@remix-run/node": "^1.19.3",
"@remix-run/react": "^1.19.3",
"@remix-run/serve": "^1.19.3",
"@types/express": "^4.17.21",
"express": "^4.18.2",
"isbot": "^3.6.8",
"mongodb": "^6.3.0",
"nodemon": "^3.0.3",
"prisma": "5.7.1",
"react": "^18.2.0",
"react-dom": "^18.2.0"
"react-dom": "^18.2.0",
"ts-node": "^10.9.2"
},
"devDependencies": {
"@remix-run/dev": "^1.19.3",
Expand All @@ -31,6 +36,6 @@
"typescript": "^5.0.4"
},
"engines": {
"node": "20.10.0"
"node": "20.6.1"
}
}
25 changes: 0 additions & 25 deletions prisma/script.ts

This file was deleted.

Loading

0 comments on commit 3cd3600

Please sign in to comment.