initial
This commit is contained in:
commit
74ae93a96e
1 changed files with 94691 additions and 0 deletions
58
joplin notion extension/Web Development/heroku/Bohr io.md
Normal file
58
joplin notion extension/Web Development/heroku/Bohr io.md
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
Bohr io
|
||||
|
||||
|
||||
|
||||
[express-template-main.zip](../../../_resources/express-template-main.zip)
|
||||
|
||||
|
||||
|
||||
server.ts
|
||||
|
||||
```jsx
|
||||
import express, { Response, Request } from "express";
|
||||
|
||||
var app = express();
|
||||
|
||||
const users = [
|
||||
{ id: 1, name: "Lucas" },
|
||||
{ id: 2, name: "Eric" },
|
||||
{ id: 3, name: "Ana" },
|
||||
];
|
||||
|
||||
|
||||
app.get("/", function (req: Request, res: Response) {
|
||||
res.send("Bohr Express template");
|
||||
});
|
||||
|
||||
app.get("/users", function (req: Request, res: Response) {
|
||||
res.send(users);
|
||||
});
|
||||
|
||||
app.get("/users/:userId", function (req: Request, res: Response) {
|
||||
const user = users.find((user) => user.id === parseInt(req.params.userId));
|
||||
res.send(user);
|
||||
});
|
||||
|
||||
if (!module.parent) {
|
||||
app.listen(3000);
|
||||
console.log("Express started on port 3000");
|
||||
}
|
||||
|
||||
export default app;
|
||||
```
|
||||
|
||||
index.ts
|
||||
|
||||
```jsx
|
||||
const serverless = require('serverless-http');
|
||||
import app from './server';
|
||||
|
||||
module.exports.handler = serverless(app);
|
||||
```
|
||||
|
||||
|
||||
Commands
|
||||
|
||||
|
||||

|
||||
|
||||
Loading…
Reference in a new issue