Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions challenges/calculadora/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM node:14-alpine

COPY . /app
WORKDIR /app
ENV PATH /app/node_modules/.bin:$PATH

RUN yarn install
RUN yarn build
EXPOSE 3000

#
# This container needs to be runned in interactive mode (tty)
#
ENTRYPOINT ["yarn", "start", "PORT=3000"]
9 changes: 9 additions & 0 deletions challenges/crud/backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM node:14-alpine

COPY . /app
WORKDIR /app

RUN yarn install
EXPOSE 3004

ENTRYPOINT ["yarn", "start", "PORT=3004"]
47 changes: 40 additions & 7 deletions challenges/crud/backend/src/controllers/CommitController.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,58 @@ const connection = require("../database/Connection");
module.exports = {

async index(req, res) {
//#Erorr002155
connection('commits').select()
.then((rows) => {
res.status(200).json(rows);
})
.catch(err => { console.log(err); throw err; });
},

async indexById(req, res) {
//#Erorr002155
connection('commits').select().where({ id: req.params.id })
.then((rows) => {
res.status(200).json(rows);
})
.catch(err => { console.log(err); throw err; });

},

async create(req, res) {
//#Erorr002155
connection.table('commits').insert({
nome: req.body['name'],
descricao: req.body['description'],
branch_id: req.body['branch']
}).then(() => {
res.status(200).json({
status: 'success'
});
}).catch(err => { console.log(err); throw err; });
},

async edit(req, res) {
//#Erorr002155
if (req.body['id'] == undefined) {
res.status(404).json();

} else {
connection.table('commits')
.where({ id: req.body['id'] })
.update({
nome: req.body['name'],
descricao: req.body['description'],
branch_id: req.body['branch']
}).then(() => {
res.status(200).json({
status: 'success'
});
}).catch(err => { console.log(err); throw err; });
}
},

async delete(req, res) {
//#Erorr002155

return res.status(204).send();
connection.table('commits').delete().where({ id: req.params.id })
.then(() => {
return res.status(204).send();
}).catch(err => { console.log(err); throw err; });
},

}
20 changes: 16 additions & 4 deletions challenges/crud/backend/src/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,22 @@ const routes = express.Router();
const BranchController = require('./controllers/BranchController');
const CommitController = require('./controllers/CommitController');

routes.get(/*'#Erroorrs12200009150'*/, /*#Erroorrs00009150*/);
routes.post(/*'#Erroorrs12200009150'*/, /*#Erroorrs00009150*/);
routes
.route('/branchs')
.get(BranchController.index)
.delete(BranchController.delete)
.post(BranchController.create)
.put(BranchController.edit);

routes.put(/*'#Erroorrs12200009150'*/, /*#Erroorrs00009150*/);
routes.delete(/*'#Erroorrs12200009150'*/, /*#Erroorrs00009150*/);
routes
.route('/commits')
.get(CommitController.index)
.post(CommitController.create)
.put(CommitController.edit);

routes
.route('/commits/:id')
.get(CommitController.indexById)
.delete(CommitController.delete)

module.exports = routes;
9 changes: 9 additions & 0 deletions challenges/crud/frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM node:14-alpine

COPY . /app
WORKDIR /app

RUN yarn install
EXPOSE 3000

ENTRYPOINT ["yarn", "start", "PORT=3000"]