Satyam Yadav
  • Me
  • Posts

Posts

June 2, 2016

Building a REST-API with Expressjs, Tabel and Postgres | Part-3

TDD; Test Driven Development of an Expressjs app with mocha and chai. Test Lets write a quick test : npm install chai-http --save-dev create a new file routes.index.test.js in test directory touch test/routes.index.test.js 'use strict'; process.env.NODE_ENV = 'test'; const chai = require('chai'); const should = chai.should(); const chaiHttp = require('chai-http'); chai.use(chaiHttp); const server = require('../server'); describe('routes : index', () => { describe('GET /', () => { it('should return json', (done) => { chai.
read more
May 2, 2016

Building a REST-API with Expressjs, Tabel and Postgres | Part-2

Setting up database and orm. Tabel : A simple orm for PostgreSQL, built over knex.js, which works with simple javascript objects and arrays. More of a table gateway that can behave like an orm, and scale back down to a table-gateway when needed. Install postgress Set up postgres and redis on your system. A repository for helping in instalations. Link Here Postgres docs : Link Redis docs: Link Configure Tabel ORM
read more
April 2, 2016

Building a REST-API with Expressjs, Tabel and Postgres | Part-1

initializing a nodejs server application and sample test with chai. Initialize npm init Server mkdir server now add index.js in server /server/index.js 'use strict'; console.log('It is working !!'); run server: node server It should print It is working !! Test We will be using mocha and chai for testing. npm install --save-dev mocha chai Create a directory test and write a sample test. mkdir test touch test/sample.js /test/sample.js 'use strict'; const chai = require('chai'); chai.
read more
  • ««
  • «
  • 1
  • 2
  • »
  • »»
© Satyam Yadav 2024