Skip to content

Commit 899c333

Browse files
committed
add celebrate, move to mjs node files
1 parent efd473e commit 899c333

27 files changed

Lines changed: 223 additions & 113 deletions

.eslintrc.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ module.exports = {
1616
// add your custom rules here
1717
rules: {
1818
'no-console': 'off',
19-
'no-throw-literal': 'off'
19+
'no-throw-literal': 'off',
20+
'require-await': 'off'
2021
}
2122
}

api/app/index.js renamed to api/app/index.mjs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
1-
const config = require('config')
2-
const database = require('../infra/mongodb')
3-
const http = require('../interfaces/index.js')
1+
2+
import config from 'config'
3+
import database from '../infra/mongodb'
4+
import http from '../interfaces/index'
45

56
// Infra
6-
const jsonwt = require('../infra/jwt')
7-
const encrypt = require('../infra/encryption')
8-
const log = require('../infra/logger')()
9-
const fileUpload = require('../infra/fileUpload')
7+
import jsonwt from '../infra/jwt'
8+
import encrypt from '../infra/encryption'
9+
import log from '../infra/logger'
10+
import fileUpload from '../infra/fileUpload'
1011

1112
// Repositories
12-
const userRepository = require('../infra/mongodb/repositories/userRepo')
13-
const artistRepository = require('../infra/mongodb/repositories/artistRepo')
14-
const imageRepository = require('../infra/mongodb/repositories/imageRepo')
13+
import userRepository from '../infra/mongodb/repositories/userRepo.mjs'
14+
import artistRepository from '../infra/mongodb/repositories/artistRepo.mjs'
15+
import imageRepository from '../infra/mongodb/repositories/imageRepo.mjs'
1516

1617
// Services
17-
const userService = require('./services/userService')
18-
const artistService = require('./services/artistService')
18+
import userService from './services/userService.mjs'
19+
import artistService from './services/artistService.mjs'
1920

2021
const dbConfig = config.get('dbConfig')
2122
const serverConfig = config.get('serverConfig')
@@ -28,7 +29,7 @@ const jwtConfig = config.get('jwtConfig')
2829
const startApp = async () => {
2930
try {
3031
const { client, db } = await database.connect(dbConfig)
31-
console.log('Connected to DB')
32+
log.info('Connected to DB')
3233

3334
const userRepo = userRepository(db)
3435
const artistRepo = artistRepository(db)
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
module.exports = ({
2+
export default ({
33
// usersRepo,
44
artistRepo,
55
imageRepo,
@@ -26,8 +26,8 @@ module.exports = ({
2626
}
2727
}
2828

29-
const addArtist = async (projectData) => {
30-
const project = ProjectEntity(projectData)
29+
const addArtist = async (project) => {
30+
// const project = ProjectEntity(projectData)
3131

3232
const createdProject = await artistRepo.createArtist(project)
3333

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
const userEntity = require('../../domain/User')
1+
import userEntity from '../../domain/User'
22

3-
module.exports = ({
3+
export default ({
44
userRepo,
55
encrypt,
66
jwt,
@@ -149,7 +149,7 @@ module.exports = ({
149149
}
150150

151151
const sendUserMail = ({ subject, email, message }) => {
152-
return sendMail(subject, email, message)
152+
// return sendMail(subject, email, message)
153153
}
154154

155155
return {

api/domain/Artist.mjs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import celebrate from 'celebrate'
2+
import { urlRegex } from '../../utils/index.mjs'
3+
4+
const { Joi } = celebrate
5+
6+
export default Joi.object({
7+
name: Joi.string().required(),
8+
genre: Joi.string().required(),
9+
content: Joi.string().required(),
10+
socialLinks: Joi.object({
11+
facebook: Joi.string(),
12+
instagram: Joi.string(),
13+
youtube: Joi.string(),
14+
videos: Joi.object({
15+
youtube: Joi.array().items(Joi.string())
16+
}),
17+
releases: Joi.array().items(
18+
Joi.object({
19+
name: Joi.string().required(),
20+
location: Joi.string().required(),
21+
link: Joi.string().pattern(urlRegex).required(),
22+
date: Joi.date().required()
23+
})
24+
)
25+
})
26+
})
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = ({ username, email, hash, salt }) => {
1+
export default ({ username, email, hash, salt }) => {
22
const user = {
33
username,
44
email,
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const crypto = require('crypto')
1+
import crypto from 'crypto'
22

33
const encryptPsw = (password) => {
44
const salt = crypto.randomBytes(16).toString('hex')
@@ -34,7 +34,7 @@ const encryptFileName = (fileName) => {
3434
console.error('This type of file is not supported !')
3535
}
3636

37-
module.exports = {
37+
export default {
3838
encryptPsw,
3939
comparePsw,
4040
encryptFileName
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
const multer = require('multer')
1+
import multer from 'multer'
22

3-
module.exports = () => {
3+
export default () => {
44
// const storage = multer.diskStorage({
55
// destination: (req, file, cb) => {
66

api/infra/jwt.js renamed to api/infra/jwt.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
const jwt = require('jsonwebtoken')
1+
import jwt from 'jsonwebtoken'
22

3-
module.exports = config => ({
3+
export default config => ({
44
signin: (id) => {
55
return jwt.sign({ id }, config.secret)
66
},

api/infra/logger.js

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)