Skip to content

Branch teste #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
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
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*/models/index.js
*/migrations/*
*/migrations/*
/tests
14 changes: 12 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
{
"extends": "eslint-config-trybe-backend"
}
"extends": "eslint-config-trybe-backend",
"rules": {
"max-lines-per-function": [
"error",
{
"max": 2000,
"skipBlankLines": true,
"skipComments": true
}
]
}
}
14 changes: 14 additions & 0 deletions .github/workflow/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: heroku-back-end

on: [push, pull_request]

jobs:
eslint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Instala dependências
run: npm install
- name: Roda ESlint
run: npm run lint
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM node:alpine

WORKDIR /app

COPY package.json .

RUN npm install

COPY . .

CMD ["node", "src/api/server.js"]
5 changes: 5 additions & 0 deletions heroku.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
build:
docker:
web: Dockerfile
run:
web: node src/api/server.js
2 changes: 1 addition & 1 deletion package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"scripts": {
"test": "jest tests",
"start": "node src/api/server",
"dev": "nodemon src/api/server"
"dev": "nodemon src/api/server",
"lint": "eslint --no-inline-config --ext .js,.jsx --no-error-on-unmatched-pattern -c .eslintrc.json ."
},
"keywords": [],
"author": "",
Expand Down
7 changes: 5 additions & 2 deletions src/api/app.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
const express = require('express');
const rescue = require('express-rescue');
const cors = require('cors');
const UserController = require('../controllers/user');
const errorMiddleware = require('../middlewares/error');

// miguek
const app = express();

app.use(cors());

app.get('/users', rescue(UserController));

app.use(errorMiddleware);
app.use(errorMiddleware);

module.exports = app;
5 changes: 3 additions & 2 deletions src/api/server.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const app = require('./app');

const PORT = 3000;
require('dotenv/config');
// hoi
const PORT = process.env.PORT || 3000;

app.listen(PORT, () => console.log(`Rodando na porta ${PORT}`));
31 changes: 19 additions & 12 deletions src/sequelize/config/config.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
require('dotenv/config');

const { HOST, PASSWORD_POSTGRES, DATABASE, DB_USERNAME, DB_PORT } = process.env;

module.exports = {
development: {
username: 'root',
password: null,
database: 'database_development',
host: '127.0.0.1',
username: DB_USERNAME,
password: PASSWORD_POSTGRES,
database: DATABASE,
host: HOST,
port: DB_PORT,
dialect: 'postgres',
},
test: {
username: 'root',
password: null,
database: 'database_test',
host: '127.0.0.1',
username: DB_USERNAME,
password: PASSWORD_POSTGRES,
database: DATABASE,
host: HOST,
port: DB_PORT,
dialect: 'postgres',
},
production: {
username: 'root',
password: null,
database: 'database_test',
host: '127.0.0.1',
username: DB_USERNAME,
password: PASSWORD_POSTGRES,
database: DATABASE,
host: HOST,
port: DB_PORT,
dialect: 'postgres',
},
};
4 changes: 2 additions & 2 deletions src/sequelize/migrations/20211020194502-create-user.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = {
},
});
},
down: async (queryInterface, Sequelize) => {
down: async (queryInterface, _Sequelize) => {
await queryInterface.dropTable('Users');
},
};
};