-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(first commit): added base work from Dosismart bridge
- Loading branch information
Showing
118 changed files
with
36,645 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Express } from "express-serve-static-core"; | ||
import { TResponder } from '../../src/Types/responseTypes' | ||
|
||
declare module 'express-serve-static-core' { | ||
interface Request { | ||
rawBody?: string, | ||
} | ||
|
||
interface IncomingMessage { | ||
rawBody?: string, | ||
originalUrl: string | ||
} | ||
|
||
interface Response { | ||
bridgeResponse: TResponder | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
FROM node:15.13 | ||
|
||
# Create app directory | ||
WORKDIR /usr/src/app | ||
|
||
# Install app dependencies | ||
# A wildcard is used to ensure both package.json AND package-lock.json are copied | ||
# where available (npm@5+) | ||
COPY package*.json ./ | ||
|
||
COPY . ./ | ||
|
||
RUN npm install | ||
RUN npm run build | ||
# If you are building your code for production | ||
# RUN npm ci --only=production | ||
|
||
# Bundle app source | ||
|
||
EXPOSE 9090 | ||
CMD [ "node", "dist/index.js" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
FROM node:10 | ||
|
||
# Create app directory | ||
WORKDIR /usr/src/app | ||
|
||
# Install app dependencies | ||
# A wildcard is used to ensure both package.json AND package-lock.json are copied | ||
# where available (npm@5+) | ||
COPY package*.json ./ | ||
|
||
COPY . ./ | ||
|
||
RUN npm install | ||
RUN npm run build | ||
|
||
# If you are building your code for production | ||
# RUN npm ci --only=production | ||
|
||
# Bundle app source | ||
|
||
EXPOSE 9090 | ||
CMD [ "npm", "test" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
[comment]: <> (modifie this, do not remove) | ||
<!-- [![Actions Status](https://github.com/{owner}/{repo}/workflows/{workflow_name}/badge.svg)](https://github.com/{owner}/{repo}/actions) --> | ||
[![Actions Status](https://github.com/BHC-IT/node-cpp-template/workflows/Node.js%20CI/badge.svg)](https://github.com/BHC-IT/node-cpp-template/actions) | ||
[![Actions Status](https://github.com/BHC-IT/node-cpp-template/workflows/tslint/badge.svg)](https://github.com/BHC-IT/node-cpp-template/actions) | ||
[![Actions Status](https://github.com/BHC-IT/node-cpp-template/workflows/cpplint/badge.svg)](https://github.com/BHC-IT/node-cpp-template/actions) | ||
|
||
# Project tree | ||
``` | ||
WASM | ||
├── addon //contain .cpp & .h files | ||
│ ├── base.cpp -> base() function | ||
│ ├── base.h -> export base() to global scope | ||
│ └── index.cpp -> expose base() function for nodejs via napi | ||
├── bindings //contain .ts file that wrap from cpp | ||
│ └── base.ts -> wrap base addon for as a ts module | ||
├── scripts // scripts to use the project | ||
│ ├── build.sh -> build the cpp files of the project | ||
│ ├── createDocker.sh -> create docker image of the project | ||
│ ├── runDocker.sh -> create container based on current image | ||
│ ├── runTestDocker.sh -> create container of a test image and destroy it after used | ||
│ └── testDocker.sh -> create test image | ||
├── src // source file for the project in .ts | ||
│ └── index.ts -> entry point of the bundle | ||
├── test // unitary test | ||
│ ├── base.cpp.test.ts -> test for base() funtion | ||
│ └── index.test.ts -> test of the entrypoint | ||
├── typings // type test file | ||
│ ├── globals | ||
│ │ └── mocha | ||
│ │ ├── index.d.ts | ||
│ │ └── typings.json | ||
│ ├── index.d.ts | ||
│ └── modules | ||
│ └── chai | ||
│ ├── index.d.ts | ||
│ └── typings.json | ||
├── binding.gyp -> configuration file for node-gyp | ||
├── Dockerfile -> docker configuration file used for creating the project image | ||
├── Dockerfile.test -> docker configuration file used for creating the test image | ||
├── nodemon.json -> configuration file for nodemon | ||
├── package.json -> configuration file for npm | ||
├── README.md | ||
├── tsconfig.json -> configuration file for typescript | ||
└── typings.json -> configuration file for typing | ||
``` | ||
|
||
# Command | ||
`npm start`: run the project in prod mode | ||
|
||
`npm run dev`: run the project in dev mode with nodemon | ||
|
||
`npm run build`: build the project. run ./scripts/build.sh | ||
|
||
`npm run clean`: clear the project. delete `dist` && `build` path | ||
|
||
`npm run test`: launch unary test | ||
|
||
`npm run docker`: create a docker image of the project. same as `npm run docker:build`. run ./scripts/createDocker.sh | ||
|
||
`npm run docker:start`: launch a docker container based on the current version image if it exist run ./scripts/runDocker.sh | ||
|
||
`npm run docker:test`: create a docker image for unite testing purpose. create a self destructing attached container of the image. run ./scripts/testDocker.sh and ./scripts/runTestDocker.sh | ||
|
||
# Dependecies | ||
```bash | ||
npm install -g typings chai mocha ts-node node-gyp | ||
``` | ||
|
||
lets break that down: | ||
|
||
`typing & chain & mocka` : unitary tests | ||
|
||
`ts-node`: compile typescript code | ||
|
||
`node-gyp`: compile C++ code | ||
|
||
# How to use | ||
|
||
First clone this repo and copy/move its content in another project folder | ||
```bash | ||
git clone https://github.com/BHC-IT/node-cpp-template.git | ||
mkdir NEW_PROJECT | ||
cp -rf node-cpp-template/* NEW_PROJECT/. | ||
``` | ||
|
||
then link the folder to your remote repository | ||
```bash | ||
cd NEW_PROJECT | ||
git init | ||
git commit -m "first commit" | ||
git remote add origin [email protected]:AUTHOR_NAME/REPO_NAME.git | ||
git push -u origin master | ||
``` | ||
You are now good to go with this template |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"watch": [".","src","addon"], | ||
"ext": ".ts,.js,.cpp,.h", | ||
"ignore": [], | ||
"exec": "ts-node ./src/index.ts" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
ip : 193.70.39.232 | ||
pwd : qHzW9vq1 | ||
pid: 82463 |
Oops, something went wrong.