Skip to content
/ fastimo Public template

Scalable monorepo based node project structure with fastify

License

Notifications You must be signed in to change notification settings

rjoydip-zz/fastimo

Repository files navigation

fastimo

Build Status Build status lerna code style: prettier License PRs Welcome

Scalable monorepo based node project structure with fastify.

Install

$ git clone https://github.com/rjoydip/fastimo.git
$ cd fastimo
$ npm install

Setup

Run following command for setup.

$ npm run setup
$ npm run app

Features

  • Scalable and Monorepo based project structure.
  • Fully working on fastify ecosystem.
  • Extend functionalities with fastify plugins.
  • Add functionality to the Fastify instance with decorate API.
  • Jest for testing.
  • prettier and eslint for linting utility
  • lerna for splitting up large codebases.
  • EJS default templating.

Scripts

  • lerna >> npm run lerna - Execute lerna locally
  • lerna help >> npm run help - Show lerna help
  • test >> npm test or npm run test - Test your code
  • lint >> npm run lint - Cheeck linting and prettier your code
  • clean >> npm run clean - Cleanup project
  • global >> npm run global- Install project CLI globally
  • app >> npm run app - Run your project

Generate package and module

  • package: npm run gen:pkg <PACKAGE_NAME>
  • module: npm run gen:mod <MODULE_NAME>

Configuration

There are three types of configuration format supported.

  • fastimo.config.js
  • fastimo.config.json
  • fastimo.config.yml

CLI

$ npm run global
$ fastimo
Welcome to fastimo

Directory Structure

fastimo
├── appveyor.yml
├── core
|  ├── cli
|  |  ├── index.js
|  |  ├── package-lock.json
|  |  ├── package.json
|  |  └── __tests__
|  |     └── index.spec.js
|  ├── config
|  |  ├── index.js
|  |  ├── package.json
|  |  ├── package-lock.json
|  |  └── __tests__
|  |     └── index.spec.js
|  ├── fastimo
|  |  ├── index.js
|  |  ├── package-lock.json
|  |  ├── package.json
|  |  └── __tests__
|  |     └── index.spec.js
|  ├── register
|  |  ├── index.js
|  |  ├── package-lock.json
|  |  ├── package.json
|  |  └── __tests__
|  |     └── index.spec.js
|  ├── render
|  |  ├── index.js
|  |  ├── package-lock.json
|  |  ├── package.json
|  |  └── __tests__
|  |     └── index.spec.js
|  └── utils
|     ├── index.js
|     ├── package-lock.json
|     ├── package.json
|     └── __tests__
|        └── index.spec.js
├── modules
|  ├── hello
|  |  ├── config.js
|  |  ├── index.js
|  |  ├── package-lock.json
|  |  ├── package.json
|  |  ├── views
|  |  |  └── index.ejs
|  |  └── __tests__
|  |     └── index.spec.js
|  └── index
|    ├── config.js
|    ├── index.js
|    ├── package.json
|    ├── views
|    |  └── index.ejs
|    └── __tests__
|        └── index.spec.js
├── jest.config.js
├── lerna.json
├── LICENSE
├── package-lock.json
├── package.json
├── readme.md
└── scripts
   ├── generate.js
   └── index.js

Benchmark

options:

-c/--connections NUM
  The number of concurrent connections to use. default: 10.
-p/--pipelining NUM
  The number of pipelined requests to use. default: 1.
-d/--duration SEC
  The number of seconds to run the autocannnon. default: 10.

Root benchmark

$ autocannon -c 100 -d 5 -p 10 localhost:3000
Running 5s test @ http://localhost:3000
100 connections with 10 pipelining factor

Stat         Avg     Stdev   Max
Latency (ms) 3.67    11.4    122.88
Req/Sec      26606.4 2711.19 29236
Bytes/Sec    4.25 MB 417 kB  4.65 MB

135k requests in 5s, 21.2 MB read

Note: Fastimo root serves 135k(max)/110-131k(avg) request in 5sec. (Response type is simple string)

View benchmark

$ autocannon -c 100 -d 5 -p 10 localhost:3000/hello?name=fastimo
Running 5s test @ http://localhost:3000/hello?name=fastimo
100 connections with 10 pipelining factor

Stat         Avg    Stdev   Max
Latency (ms) 18.2   54.81   242.32
Req/Sec      5371.6 415.82  5980
Bytes/Sec    757 kB 53.2 kB 843 kB

28k requests in 5s, 3.79 MB read

Note: Fastimo view serves 28k(max)/23-27k(avg) request in 5sec. (Response type is ejs view)

TODO

  • Test
  • CLI

License

MIT © Joydip Roy

About

Scalable monorepo based node project structure with fastify

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published