Skip to content

Commit

Permalink
plop updated
Browse files Browse the repository at this point in the history
  • Loading branch information
lipex360x committed Jan 8, 2022
1 parent 17ee16e commit 7d5c3b6
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 29 deletions.
6 changes: 3 additions & 3 deletions .vscode/snippets.code-snippets
Original file line number Diff line number Diff line change
Expand Up @@ -370,9 +370,9 @@
"body": [
"arrayFiles.push({",
" data: {},",
" path: '../../xxx',",
" name: 'fileName.ts',",
" template: 'teste.hbs',",
" path: `\\${generatePath}/xxxx`,",
" name: '${1:fileName}.ts',",
" template: '${2:templateName}.hbs',",
" force: false",
"})",
]
Expand Down
6 changes: 5 additions & 1 deletion src/shared/generators/seeds/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,23 @@ module.exports = {
],

actions: (data) => {
const pathTemplate = './seeds/templates'
const generatePath = '../../shared/infra/typeorm/seeds'

const files = () => {
const arrayFiles = []

arrayFiles.push({
data: {},
path: '../../shared/infra/typeorm/seeds',
path: generatePath,
name: '{{pascalCase name}}.ts',
template: 'seed.hbs',
force: false
})

return arrayFiles
}

// Create Files
const action = []

Expand Down
49 changes: 42 additions & 7 deletions src/shared/generators/start/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,55 @@ module.exports = {
],

actions: (data) => {
const action = [
{
type: 'add',
path: '../../../.env',
const pathTemplate = './start/templates'
const generatePath = '../../..'

const files = () => {
const arrayFiles = []
// env
arrayFiles.push({
data: {
jwtToken: generateId(16),
jwtExpires: '30m',
jwtExpires: '60m',
refreshToken: generateId(12),
refreshExpires: '7d',
projectMail: `noreply@${camelCase(data.projectName)}.com`
},
templateFile: './start/templates/env.hbs'
path: generatePath,
name: '.env',
template: 'env.hbs',
force: true
})

arrayFiles.push({
data: {},
path: `${generatePath}`,
name: 'docker-compose.yml',
template: 'docker-compose.hbs',
force: true
})

return arrayFiles
}
// Create Files
const action = []

files().forEach(file => {
const createFile = {
type: 'add',
path: `${file.path}/${file.name}`,
data: file.data,
templateFile: `${pathTemplate}/${file.template}`,
force: !!file.force
// force: true
}
]

action.push(createFile)
})

// Message
const message = () => 'APP Startup files created'
action.push(message)

return action
}
Expand Down
28 changes: 14 additions & 14 deletions src/shared/generators/start/templates/docker-compose.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3.7"

services:
postgresdb:
image: bitnami/postgresql:latest
image: bitnami/postgresql
container_name: ${TYPEORM_CONTAINER_NAME}
environment:
- POSTGRES_USER=${TYPEORM_USERNAME}
Expand All @@ -12,20 +12,20 @@ services:
- pgdata:/data/postgres
network_mode: host

# mongodb:
# image: bitnami/mongodb:latest
# container_name: ${MONGODB_CONTAINER_NAME}
# environment:
# - ALLOW_EMPTY_PASSWORD=no
# - MONGODB_USERNAME=${MONGO_USER}
# - MONGODB_PASSWORD=${MONGO_PASS}
# - MONGODB_DATABASE=${MONGO_DB}
# network_mode: host
mongodb:
image: bitnami/mongodb:latest
container_name: ${MONGODB_CONTAINER_NAME}
# environment:
# - ALLOW_EMPTY_PASSWORD=no
# - MONGODB_USERNAME=${MONGO_USER}
# - MONGODB_PASSWORD=${MONGO_PASS}
# - MONGODB_DATABASE=${MONGO_DB}
network_mode: host

# redisdb:
# image: redis:alpine
# container_name: ${REDIS_CONTAINER_NAME}
# network_mode: host
redisdb:
image: redis:alpine
container_name: ${REDIS_CONTAINER_NAME}
network_mode: host

volumes:
pgdata:
Expand Down
1 change: 0 additions & 1 deletion src/shared/generators/useCases/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ module.exports = {
})

// Message
console.log('hello useCase')
const message = () => (`UseCase ${capitalize(data.moduleName)}/${capitalize(data.useCaseName)}/${capitalize(data.actionName)} created`)
action.push(message)

Expand Down
6 changes: 3 additions & 3 deletions src/shared/middlewares/rateLimiter/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NextFunction, Request, Response } from 'express'
import { Request, Response, NextFunction } from 'express'
import { RateLimiterRedis } from 'rate-limiter-flexible'
import Redis from 'ioredis'

Expand All @@ -14,12 +14,12 @@ const limiter = new RateLimiterRedis({
duration: 1
})

export default async function rateLimiterMiddleware (request:Request, response:Response, next:NextFunction): Promise<void> {
export default async function rateLimiter (request: Request, response: Response, next: NextFunction): Promise<void> {
try {
await limiter.consume(request.ip)

return next()
} catch {
} catch (err) {
throw new AppError('Too many requests', 429)
}
}

0 comments on commit 7d5c3b6

Please sign in to comment.