Skip to content

Commit

Permalink
[RELEASE] Production Release 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
chrnx-dev committed Sep 11, 2019
2 parents 685ecc7 + a542f15 commit 1aa9cfb
Show file tree
Hide file tree
Showing 17 changed files with 421 additions and 69 deletions.
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
language: node_js
node_js:
- "10"
before_script:
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter
- ./cc-test-reporter before-build
script: npm test
env:
- CODECOV_TOKEN="3dab63ec-b748-4e67-8d23-9f3a998281f3"
- CC_TEST_REPORTER_ID="bd26cc6c907283d1564f5f881621984f3414461bb36c5005aa0bf3b47e2dac9b"

after_success:
- bash <(curl -s https://codecov.io/bash)
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
82 changes: 65 additions & 17 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,67 @@
## CHANGELOG

# Change Log
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).


## [0.0.6-RC1] - 2019-06-19

First Production ready release.

### Added
- Change Documentation.
### Changed

### Fixed

[Current]

- [7244473](https://github.com/Zero-OneiT/expresive-tea/commit/7244473e158e14b5a2f0217ed8aedcc69c0d310c) [FEATURE] Adding Plugin Structure
- [997700f](https://github.com/Zero-OneiT/expresive-tea/commit/997700f8492c31d53e95f97d22f12e11351e949a) [FEATURE] Adding Plugin Structure
- [a2f08a1](https://github.com/Zero-OneiT/expresive-tea/commit/a2f08a12489a4032096cfd9f0fa034b56918993d) [REFACTORING] Improve Code
- [ce043f5](https://github.com/Zero-OneiT/expresive-tea/commit/ce043f53db0df0d7408e264bf63e1b519a1f2987) [REFACTORING] Improve Code
- [8372d66](https://github.com/Zero-OneiT/expresive-tea/commit/8372d66455b571a8c514d1e51b162cc2112e3b30) [REFACTORING] Improve Code
- [9e9dab7](https://github.com/Zero-OneiT/expresive-tea/commit/9e9dab7874181c6866a5ad451fc5d37aad34e3ba) [REFACTORING] Improve Code
- [156e2b0](https://github.com/Zero-OneiT/expresive-tea/commit/156e2b024d65a5e553f41a9e41cf0e9d3e07578a) [REFACTORING] Improve Code
- [e704314](https://github.com/Zero-OneiT/expresive-tea/commit/e704314f62cb8504a4bdd9445d2f3cb5925b9d4f) [TEST] Benchmark Test
- [8b8cd95](https://github.com/Zero-OneiT/expresive-tea/commit/8b8cd959f089376f6867721c01eb86993c1ef362) [BADGES] Added Test Coverage on Code Climate
- [5943334](https://github.com/Zero-OneiT/expresive-tea/commit/59433346f19fd44fa003d5a118d671573b639d79) [DOCUMENTATION] Update Badges
- [7e933cc](https://github.com/Zero-OneiT/expresive-tea/commit/7e933cc91260dc2527b827fc6ec089e77af97f99) Add license scan report and status

[v0.1.1]

- [e73992e](https://github.com/Zero-OneiT/expresive-tea/commit/e73992e27618e919c19d5d39e04c15e4fe821e0c) [RELEASE] Version bump
- [c7039b9](https://github.com/Zero-OneiT/expresive-tea/commit/c7039b97bb72a5ef257527d74ffad7d84229d37a) [IMPROVEMENT] Improve Code
- [b59fcbf](https://github.com/Zero-OneiT/expresive-tea/commit/b59fcbf0fddc1ee3eb911e6adcfb9d4eb0428d10) [IMPROVEMENT] Improve Code
- [fbb179a](https://github.com/Zero-OneiT/expresive-tea/commit/fbb179ae1e90f3814edcb0fe6c055c822ae708dd) [IMPROVEMENT] Improve Code

[v0.1.0]

- [9076aa4](https://github.com/Zero-OneiT/expresive-tea/commit/9076aa469fe93bd6c6c58faad16f3ae982da1682) [DOCUMENTATION] Added Correct Path to documentation
- [2060f5b](https://github.com/Zero-OneiT/expresive-tea/commit/2060f5b9acae0cae6e072442d38e35528b9b3331) [DOCUMENTATION] Added Correct Path to documentation
- [461508b](https://github.com/Zero-OneiT/expresive-tea/commit/461508b4f3a09d20f7fa953a554a7f417582f12e) [TESTING FRAMEWORK] Codecov
- [69e7972](https://github.com/Zero-OneiT/expresive-tea/commit/69e7972b84c2fb3fd1763c4ff825be16403da31f) [TESTING FRAMEWORK] Codecov
- [8fc0aee](https://github.com/Zero-OneiT/expresive-tea/commit/8fc0aee02f1b0d3cfca5238f70dc5177f44a5f5a) [TESTING FRAMEWORK] Codecov
- [5c945bd](https://github.com/Zero-OneiT/expresive-tea/commit/5c945bd986ceb0daae7e49208e9e0012563f3cac) [TEST] Remove Cache from Travis
- [b4b552c](https://github.com/Zero-OneiT/expresive-tea/commit/b4b552ce1a454570beaca10b067aaf2d4c38072a) [TESTING FRAMEWORK] Jest and Travis
- [04924ea](https://github.com/Zero-OneiT/expresive-tea/commit/04924eafb9048cb3c6d3f5a7018b74fd843ca432) [TEST] Test Framework - Adding jest as test framework. - Adding tests
- [e75374d](https://github.com/Zero-OneiT/expresive-tea/commit/e75374da6f9663d2b2cbe36ffecc29f7f798d97b) [DOCUMENTATIOM] JSDocs Tags and Documentation
- [03ecdaa](https://github.com/Zero-OneiT/expresive-tea/commit/03ecdaaa9050b2fbea479bf62369d17f6eafb198) [DOCUMENTATION] Added Project Documentation

[v0.0.7-RC]

- [97c08a1](https://github.com/Zero-OneiT/expresive-tea/commit/97c08a16cb5c0f0fd5f89132d8337f3958354bdb) [RELEASE] Moving Release
- [f1cf891](https://github.com/Zero-OneiT/expresive-tea/commit/f1cf891a438cff86944063008d7e6258715037ce) [BUGFIX] Fixing Types and Plugin order.
- [4caab3f](https://github.com/Zero-OneiT/expresive-tea/commit/4caab3ff98a669413263765dd40580822b959bdc) [BUGFIX] Fixing Types and Plugin order.
- [5f509e0](https://github.com/Zero-OneiT/expresive-tea/commit/5f509e0947724077a5562c9c05625729081f0d08) [REFACTORING] Inverse plugin order and types.

[0.0.6-RC1]

- [034a257](https://github.com/Zero-OneiT/expresive-tea/commit/034a2576003b6b8b24e0508dd4129b84867a0864) Create CODE_OF_CONDUCT.md
- [694bd30](https://github.com/Zero-OneiT/expresive-tea/commit/694bd3020035c6fd86f8cb7a4d3a314955cdf927) [RELEASE] Adding New Release Candidate Version
- [0a2ce1f](https://github.com/Zero-OneiT/expresive-tea/commit/0a2ce1f78d3156fa5813ce2d8ad811a629957223) [RELEASE] Adding New Release Candidate Version
- [3e99f7c](https://github.com/Zero-OneiT/expresive-tea/commit/3e99f7c6ecff1d48e230a1314582a9f7c0421dae) Update issue templates
- [f5a13c3](https://github.com/Zero-OneiT/expresive-tea/commit/f5a13c3173ec5240fd73c8765b54c8c2e271e786) Pump Version
[0.0.1-pre]
- [f6f2433](https://github.com/Zero-OneiT/expresive-tea/commit/f6f2433903bbd276fb833727fd3fb58a537bfa21) [REFACTORING] Move to Beta Version
- [f8b5b69](https://github.com/Zero-OneiT/expresive-tea/commit/f8b5b690a04d0d457d833532522b93ca27388a8e) [REFACTORING] Move to Beta Version
- [fa38af9](https://github.com/Zero-OneiT/expresive-tea/commit/fa38af9340c8f56689c44f685e455f91bf2de91a) Update README.md
- [822b58e](https://github.com/Zero-OneiT/expresive-tea/commit/822b58e50f4181d5bab2c38835f8813e9d5811d7) [REFACTORING] Move to Beta Version
- [4c0642f](https://github.com/Zero-OneiT/expresive-tea/commit/4c0642f54153f85623c116e527494d9ee6f615f3) Added Boot
- [e141c45](https://github.com/Zero-OneiT/expresive-tea/commit/e141c450858ad80d2dbb5eb4b51be89c9fa6b1c1) [REFACTOR] Remove Packages
- [88583c1](https://github.com/Zero-OneiT/expresive-tea/commit/88583c1f0e0b1a09b94c7e5018c534dd62aae1cc) [REFACTOR] Remove Packages
- [86df5af](https://github.com/Zero-OneiT/expresive-tea/commit/86df5af191d5b387b4225b1ed85d8e18a57dab03) [REFACTOR] Remove Packages
- [544c088](https://github.com/Zero-OneiT/expresive-tea/commit/544c088e79a96d108104bafd5b7ba61910296a0a) [REFACTOR] Change Paths to Relative
- [bd63528](https://github.com/Zero-OneiT/expresive-tea/commit/bd63528a105c8d5c4bf1630da225ff46a8dce051) [REFACTOR] Change Paths to Relative
- [8e3b5b7](https://github.com/Zero-OneiT/expresive-tea/commit/8e3b5b7696a1e3b57aa884fc7a7e21a3f2928e20) [REFACTOR] Change to be package
- [cc2f8df](https://github.com/Zero-OneiT/expresive-tea/commit/cc2f8df37610e815b4777fa4dde875514663f050) [REFACTOR] Change to be package
- [540e276](https://github.com/Zero-OneiT/expresive-tea/commit/540e276b06a3aa5d6bc437547fcfcf02b8e7403a) [REFACTOR] Change to be package
- [bfa71a6](https://github.com/Zero-OneiT/expresive-tea/commit/bfa71a6a421fdeee0b345a047189c0a6b8d4e4d3) [REFACTOR] Change to be package
- [753f328](https://github.com/Zero-OneiT/expresive-tea/commit/753f328e617a8e9e8f7f4b297a4d7f4350785bda) [INITIAL] Added Test Configuration and Code Improvements.
- [63f64d1](https://github.com/Zero-OneiT/expresive-tea/commit/63f64d11646451bd9b5d92d5a12ff625a9ab42c2) [INITIAL] Initialize Commit
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
[![Known Vulnerabilities](https://snyk.io//test/github/Zero-OneiT/expresive-tea/badge.svg?targetFile=package.json)](https://snyk.io//test/github/Zero-OneiT/expresive-tea?targetFile=package.json)
[![Build Status](https://travis-ci.org/Zero-OneiT/expresive-tea.svg?branch=develop)](https://travis-ci.org/Zero-OneiT/expresive-tea)
[![codecov](https://codecov.io/gh/Zero-OneiT/expresive-tea/branch/develop/graph/badge.svg)](https://codecov.io/gh/Zero-OneiT/expresive-tea)
[![Package Quality](https://npm.packagequality.com/shield/@zerooneit/expressive-tea.svg)](https://packagequality.com/#?package=@zerooneit/expressive-tea)
[![Maintainability](https://api.codeclimate.com/v1/badges/6bd5ef9d884a295c7f2b/maintainability)](https://codeclimate.com/github/Zero-OneiT/expresive-tea/maintainability)
![npm](https://img.shields.io/npm/dw/@zerooneit/expressive-tea)
![GitHub issues](https://img.shields.io/github/issues/Zero-OneIT/expresive-tea)
![GitHub](https://img.shields.io/github/license/Zero-OneIT/expresive-tea)
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2FZero-OneiT%2Fexpresive-tea.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2FZero-OneiT%2Fexpresive-tea?ref=badge_shield)
> A Typescript library to create RESTful Services.
## Description
Expand Down Expand Up @@ -205,5 +206,8 @@ See also the list of [contributors](https://github.com/Zero-OneiT/expresive-tea/

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details
This project is licensed under the Apache-2.0 License - see the [LICENSE](LICENSE) file for details



[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2FZero-OneiT%2Fexpresive-tea.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2FZero-OneiT%2Fexpresive-tea?ref=badge_large)
18 changes: 16 additions & 2 deletions __test__/unit/classes/boot.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,19 @@ describe('Boot Class', () => {
}
}

class DefaultBootstrap extends Boot {}

test('should start server as default', async () => {
const boot = new DefaultBootstrap();
await boot.start();

expect(express).toHaveBeenCalled();
expect(boot.settings).toBeInstanceOf(Settings);
expect(boot.settings).toEqual(Settings.getInstance());
expect(serverMock.listen).toHaveBeenCalled();
expect(registerMock).not.toHaveBeenCalled();
});

test('should create instance correctly', () => {
const boot = new Bootstrap();

Expand All @@ -47,11 +60,12 @@ describe('Boot Class', () => {
});

test('should not fail if soft plugin fails', async () => {
softPluginMock.mockRejectedValue(false);
softPluginMock.mockImplementationOnce(() => {
throw new Error('Test');
});
const boot = new Bootstrap();

expect(boot.start()).resolves.toEqual({ application: expect.anything(), server: expect.anything() });
softPluginMock.mockReset();
});

test('should not fail if soft plugin fails', async () => {
Expand Down
62 changes: 61 additions & 1 deletion __test__/unit/decorators/server.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import Boot from '../../../classes/Boot';
import Metadata from '../../../classes/MetaData';
import ExpressiveTeaPlugin from '../../../classes/Plugin';
import Settings from '../../../classes/Settings';
import { Plug, RegisterModule, ServerSettings, Setting } from '../../../decorators/server';
import { Plug, Pour, RegisterModule, ServerSettings, Setting } from '../../../decorators/server';
import { BOOT_STAGES, BOOT_STAGES_KEY, REGISTERED_MODULE_KEY } from '../../../libs/constants';

describe('ServerSettings Decorator', () => {
Expand All @@ -10,15 +12,18 @@ describe('ServerSettings Decorator', () => {
})
class Test {
}

this.testClass = new Test();
expect(Settings.getInstance().getOptions()).toEqual({ port: 8080 });
});

test('should modify server settings as default options', () => {
Settings.reset();

@ServerSettings()
class Test {
}

this.testClass = new Test();
expect(Settings.getInstance().getOptions()).toEqual({ port: 3000 });
});
Expand Down Expand Up @@ -57,6 +62,61 @@ describe('Plug Decorator', () => {
});
});

describe('Pour Decorator', () => {
beforeAll(() => {
this.spyMetadataSet = jest.spyOn(Metadata, 'set');

class TestPlugin extends ExpressiveTeaPlugin {
readonly name = 'Test';
readonly stage = BOOT_STAGES.INITIALIZE_MIDDLEWARES;

async register(server, settings) {
}
}

class TestFailPlugin extends ExpressiveTeaPlugin {
readonly name = 'Test';
readonly stage = BOOT_STAGES.INITIALIZE_MIDDLEWARES;
readonly required = true;
}

@Pour(TestPlugin)
class Test {
}

@Pour(TestFailPlugin)
class TestFail extends Boot {
}

this.TestClass = Test;
this.TestFailClass = TestFail;
});

afterAll(() => {
this.spyMetadataSet.mockRestore();
});

test('should attach plug to respective level', () => {
this.testInstance = new this.TestClass();
const args = this.spyMetadataSet.mock.calls[0];

expect(args[0]).toEqual(BOOT_STAGES_KEY);
expect(args[1]['1'][0]).toEqual(
expect.objectContaining({
isPlugin: true,
name: 'Test',
required: false
})
);
expect(args[2]).toEqual(this.TestClass);
});

test('should attach plug to respective level', () => {
this.testInstance = new this.TestFailClass();
expect(this.testInstance.start()).rejects.toEqual(expect.anything());
});
});

describe('Setting Decorator', () => {
beforeEach(() => {
@ServerSettings({
Expand Down
24 changes: 24 additions & 0 deletions benchmark/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
.PHONY: all
all: simple fibonnaci

simple:
@./run 1 server.ts
@./run 5 server.ts
@./run 10 server.ts
@./run 15 server.ts
@./run 20 server.ts
@./run 30 server.ts
@./run 50 server.ts
@./run 100 server.ts
@echo

fibonnaci:
@./run 1 fibonnaci.ts
@./run 5 fibonnaci.ts
@./run 10 fibonnaci.ts
@./run 15 fibonnaci.ts
@./run 20 fibonnaci.ts
@./run 30 fibonnaci.ts
@./run 50 fibonnaci.ts
@./run 100 fibonnaci.ts
@echo
36 changes: 36 additions & 0 deletions benchmark/fibonnaci.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import Boot from '../classes/Boot';
import { Plug, ServerSettings } from '../decorators/server';
import { BOOT_STAGES } from '../libs/constants';

function middlewares(application) {
let n = parseInt(process.env.MW || '1', 10);
console.log(' %s middleware', n);

while (n--) {
application.use((req, res, next) => next());
}

application.use((req, res) => res.json({ data: fibonacci(100000)}));
}

function fibonacci(num) {
let a = 0;
let b = 1;
let temp;

while (num > 0) {
temp = b;
b = b + a;
a = temp;
num--;
}
return a;
}

@ServerSettings({ port: 8888 })
@Plug(BOOT_STAGES.APPLICATION, 'Benchmark Fibonnaci', middlewares, true)
class Test extends Boot {
}

const server = new Test();
export default server.start();
16 changes: 16 additions & 0 deletions benchmark/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

echo
MW=$1 ts-node --project tsconfig.json $2 &
pid=$!

sleep 2

wrk 'http://localhost:8888/?foo[bar]=baz' \
-d 3 \
-c 50 \
-t 8 \
| grep 'Requests/sec' \
| awk '{ print "- " $2 " Request/Sec"}'

kill $pid
22 changes: 22 additions & 0 deletions benchmark/server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import Boot from '../classes/Boot';
import { Plug, ServerSettings } from '../decorators/server';
import { BOOT_STAGES } from '../libs/constants';

function middlewares(application) {
let n = parseInt(process.env.MW || '1', 10);
console.log(' %s middleware', n);

while (n--) {
application.use((req, res, next) => next());
}

application.use((req, res) => res.send('Hello World'));
}

@ServerSettings({ port: 8888 })
@Plug(BOOT_STAGES.APPLICATION, 'Benchmark Hello World', middlewares, true)
class Test extends Boot {
}

const server = new Test();
export default server.start();
21 changes: 21 additions & 0 deletions benchmark/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"compilerOptions": {
"baseUrl": ".",
"sourceMap": false,
"noEmit": true,
"noImplicitAny": false,
"target": "es6",
"lib": [
"es6",
"dom"
],
"module": "commonjs",
"moduleResolution": "node",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"declaration": true
},
"include": [
"../"
]
}
Loading

0 comments on commit 1aa9cfb

Please sign in to comment.