Skip to content

Instantly share code, notes, and snippets.

View chukwuemekachm's full-sized avatar
💯
A winner is a dreamer who never gives up --- Nelson_Mandela

Chima Chukwuemeka chukwuemekachm

💯
A winner is a dreamer who never gives up --- Nelson_Mandela
View GitHub Profile
@chukwuemekachm
chukwuemekachm / review.js
Created January 30, 2019 15:17
The Review model for Introduction to sequelize tutorial.
'use strict';
module.exports = (sequelize, DataTypes) => {
const Review = sequelize.define(
'Review',
{
title: {
type: DataTypes.STRING,
allowNull: false,
validate: {
len: [2, 100],
@chukwuemekachm
chukwuemekachm / book.js
Last active February 11, 2019 22:15
The Book model file for Introduction to sequelize tutorial
'use strict';
const Op = require('sequelize').Op;
module.exports = (sequelize, DataTypes) => {
const Book = sequelize.define(
'Book',
{
title: {
type: DataTypes.STRING,
allowNull: false,
@chukwuemekachm
chukwuemekachm / 20190129001701-create-review.js
Created January 30, 2019 15:12
Create review migration file for Introduction to sequelize tutorial.
'use strict';
module.exports = {
up: (queryInterface, Sequelize) =>
queryInterface.createTable('Reviews', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER,
},
@chukwuemekachm
chukwuemekachm / 20190129001701-create-book.js
Created January 30, 2019 15:11
Create book migration file for the Introduction to sequelize course.
'use strict';
module.exports = {
up: (queryInterface, Sequelize) =>
queryInterface.createTable('Books', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER,
},
@chukwuemekachm
chukwuemekachm / .sequelizerc
Created January 28, 2019 22:55
This is the file needed by the sequelize-cli to bootstrap a sequelize project.
const path = require('path');
module.exports = {
'config': path.resolve('server', 'config', 'database.js'),
'models-path': path.resolve('server', 'sequelize', 'models'),
'seeders-path': path.resolve('server', 'sequelize', 'seeders'),
'migrations-path': path.resolve('server', 'sequelize', 'migrations')
}
@chukwuemekachm
chukwuemekachm / server-routes-index.js
Created January 28, 2019 22:52
This is the index file and entry point for the router in the routes folder.
import { Router } from 'express';
const router = Router();
router.get('/', (req, res, next) =>
res.status(200).json({
message: 'Welcome to Books REST API by The JavaScript Dojo',
}),
);
@chukwuemekachm
chukwuemekachm / index.js
Created January 28, 2019 22:46
This is the index file and entry point for the Introduction to Sequelize course on The JavaScript Dojo.
import express from 'express';
import bodyParser from 'body-parser';
import helmet from 'helmet';
import router from './routes';
const app = express();
const { NODE_ENV, PORT = 3000 } = process.env;
const isProduction = NODE_ENV === 'production';
@chukwuemekachm
chukwuemekachm / .babelrc
Created August 17, 2018 09:45
Http client module to interact with COPYLEAKS_API
{
"presets": [
"env"
]
}
@chukwuemekachm
chukwuemekachm / tdd.test.js
Created July 23, 2018 13:38
This is a single TDD test using mocha, chai and chai-http. The test tests that the user's token is valid and returns an Invalid auth token response.
// import describe and it from mocha as named exports
import { describe, it } from 'mocha';
// import chai and chai-http from chai and chai-http libraries as default exports
import chai from 'chai';
import chaiHttp from 'chai-http';
// import server from index.js as default export
import server from '../../index';
/*
* initialise chai to use chai-http
@chukwuemekachm
chukwuemekachm / 31.css
Last active April 19, 2018 13:26
Framework 31
/*
* 31.css is a css library created by CHIMA CHUKWUEMEKA [email protected]
* for the Book-A-Meal project in Andela Cycle 31 Nigeria 2018
*
* Just like w3.css, 31.css implores the same terminologies in order to provide a responsive UI
* To use 31.css, call to-[property] you want to call as a class attribute value e.g
* to-table, to-btn e.t.c
*/
* {