- yarn init
- yarn add -D typescript //lib
- yarn tsc --init // run a script
- mkdir src
- yarn tsc // to create a JS file of TS files
- package.json // do this to not run the line 3.
"scripts": {
"build":"tsc"
},
- tsconfig.json uncomment outDir and write dist
- git init
- .gitignore
- yarn add express // add some libs
- yarn add -D ts-node
- yarn add -D nodemon
- mkdir src/index.ts
/* eslint-disable linebreak-style */
import express from 'express';
const app = express();
const port = 3002;
app.listen(port,()=>{
console.log(`Server is runnig:http://localhost:${port}`);
});
- docker run --name mongo -p 27017:27017 -d mongo:4.4.6
- yarn add mongoose//pra fazer conxão com mongodb
- index.ts
import mongoose from 'mongoose';
mongoose.connect('mongodb://localhost:27017')
.then(()=>{
//Só pode se conectar com a api se a conexão com
//o banco de dados der certo
const app = express();
const port = 3002;
app.listen(port,()=>{
console.log(`Server is runnig:http://localhost:${port}`);
});
})
.catch(()=>console.log('Erro ao conectar no mongodb'));
- mkdir app/models
- create the models Category,Order,Product