This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @component('mail::layout') | |
| {{-- Header --}} | |
| @slot('header') | |
| @component('mail::header', ['url' => config('app.url')]) | |
| Wonderful Company | |
| @endcomponent | |
| @endslot | |
| Dear {{$user->name}} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import fs from 'fs'; | |
| import path from 'path'; | |
| import Sequelize from 'sequelize'; | |
| import configJson from '../config/config'; | |
| const basename = path.basename(__filename); | |
| const env = process.env.NODE_ENV ? process.env.NODE_ENV : 'development'; | |
| const config = configJson[env]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require('dotenv').config(); | |
| module.exports = { | |
| // If using onine database | |
| // development: { | |
| // use_env_variable: 'DATABASE_URL' | |
| // }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module.exports = (sequelize, DataTypes) => { | |
| const Book = sequelize.define('Book', { | |
| title: { | |
| type: DataTypes.STRING, | |
| allowNull: false, | |
| }, | |
| price: { | |
| type: DataTypes.STRING, | |
| allowNull: false, | |
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module.exports = { | |
| up: (queryInterface, Sequelize) => { | |
| return queryInterface.createTable('Books', { | |
| id: { | |
| allowNull: false, | |
| autoIncrement: true, | |
| primaryKey: true, | |
| type: Sequelize.INTEGER | |
| }, | |
| title: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import database from '../src/models'; | |
| class BookService { | |
| static async getAllBooks() { | |
| try { | |
| return await database.Book.findAll(); | |
| } catch (error) { | |
| throw error; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import BookService from '../services/BookService'; | |
| import Util from '../utils/Utils'; | |
| const util = new Util(); | |
| class BookController { | |
| static async getAllBooks(req, res) { | |
| try { | |
| const allBooks = await BookService.getAllBooks(); | |
| if (allBooks.length > 0) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export default class Util { | |
| constructor() { | |
| this.statusCode = null; | |
| this.type = null; | |
| this.data = null; | |
| this.message = null; | |
| } | |
| setSuccess(statusCode, message, data) { | |
| this.statusCode = statusCode; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Router } from 'express'; | |
| import BookController from '../controllers/BookController'; | |
| const router = Router(); | |
| router.get('/', BookController.getAllBooks); | |
| router.post('/', BookController.addBook); | |
| router.get('/:id', BookController.getABook); | |
| router.put('/:id', BookController.updatedBook); | |
| router.delete('/:id', BookController.deleteBook); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import config from 'dotenv'; | |
| import express from 'express'; | |
| import bodyParser from 'body-parser'; | |
| import bookRoutes from './server/routes/BookRoutes'; | |
| config.config(); | |
| const app = express(); | |
| app.use(bodyParser.json()); |