Skip to content

Example of a simple microservice, written with Node.js 8, Restify 6, Mongoose 4 for MongoDB, and Typescript 2.6.

Notifications You must be signed in to change notification settings

garystafford/restify-mongo-typescript-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Restify-Mongoose-TypeScript Microservice

Work in progress...

Example of a simple microservice, written with Node.js 8.x, Restify 6.x, Mongoose 4.x for MongoDB, and Typescript 2.6. Original project structure based on restify-typescript-seed GitHub project.

Project built in Visual Studio 2017 on Windows using the TypeScript Node.js template.

Working with Project

# recommend using yarn instead of npm
npm install -g yarn

# install node packages
yarn
yarn install

# install typescript globally
yarn global add typescript
tsc --version # 2.6.1

# build continuously
tsc --watch

# transpile typescript
yarn run compile

# mocha for testing
yarn global add mocha

# test (transpiles first)
yarn test

# start (transpiles first)
yarn start

# test local HTTP GET endpoint
curl http://localhost:3000/widgets

# kill node process(es) on Windows
taskkill /F /IM node.exe

Mongo Import Sample Data

Import the supplied set of sample widget documents into the local development instance of MongoDB from the supplied 'data/widgets.json' file.

# windows
SET MONGO_URL=localhost:27017
SET MONGO_USERNAME=<your_username>
SET MONGO_PASSWORD=<your_password>

mongoimport ^
  --host %MONGO_URL% ^
  --username %MONGO_USERNAME% ^
  --password %MONGO_PASSWORD% ^
  --authenticationDatabase admin ^
  --db node-restify-mongodb-development ^
  --collection widgets ^
  --file data/widgets.json ^
  --drop --jsonArray --verbose

SonarQube

Test TypeScript files. Requires SonarQube.

# windows
sonar-scanner ^
  -Dsonar.projectKey=WidgetService ^
  -Dsonar.sources=. ^
  -Dsonar.inclusions=app/**,test/**

About

Example of a simple microservice, written with Node.js 8, Restify 6, Mongoose 4 for MongoDB, and Typescript 2.6.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published