-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bump version, revamped tests, README and other helpful files
- Loading branch information
Showing
13 changed files
with
217 additions
and
284 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,3 @@ | ||
MONGODB_URL=mongodb://localhost:27017 | ||
MONGODB_DB_NAME=net-db | ||
API_BASE_URL=http://host.docker.internal:8082 |
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,46 @@ | ||
# Code of Conduct | ||
|
||
## Our Pledge | ||
|
||
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. | ||
|
||
## Our Standards | ||
|
||
Examples of behavior that contributes to creating a positive environment include: | ||
|
||
- Using welcoming and inclusive language | ||
- Being respectful of differing viewpoints and experiences | ||
- Gracefully accepting constructive criticism | ||
- Focusing on what is best for the community | ||
- Showing empathy towards other community members | ||
|
||
Examples of unacceptable behavior by participants include: | ||
|
||
- The use of sexualized language or imagery and unwelcome sexual attention or advances | ||
- Trolling, insulting/derogatory comments, and personal or political attacks | ||
- Public or private harassment | ||
- Publishing others' private information, such as a physical or electronic address, without explicit permission | ||
- Other conduct which could reasonably be considered inappropriate in a professional setting | ||
|
||
## Our Responsibilities | ||
|
||
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. | ||
|
||
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned with this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. | ||
|
||
## Scope | ||
|
||
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. | ||
|
||
## Enforcement | ||
|
||
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [[email protected]](mailto:[email protected]). All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. | ||
|
||
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. | ||
|
||
## Attribution | ||
|
||
This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org/version/2/0/code_of_conduct.html), version 2.0, available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. | ||
|
||
For answers to common questions about this code of conduct, see https://www.contributor-covenant.org/faq | ||
|
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,43 @@ | ||
# Contributing to Tokenguard Dashboard Builder Client | ||
|
||
Thank you for considering contributing to the Tokenguard Dashboard Builder Client! Your help is essential for improving the project and making it even better. | ||
|
||
## Code of Conduct | ||
|
||
Please note that this project adheres to the [Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project, you agree to abide by its terms. | ||
|
||
## How Can I Contribute? | ||
|
||
### Reporting Bugs | ||
|
||
If you come across a bug while using the Tokenguard Dashboard Builder Client, we appreciate it if you could [open an issue](https://github.com/tokenguardio/dashboard-creator-client/issues) on our GitHub repository. When reporting a bug, please include the following details: | ||
|
||
- A clear and descriptive title | ||
- Steps to reproduce the bug | ||
- Expected behavior | ||
- Actual behavior | ||
- Any error messages or screenshots if applicable | ||
|
||
### Suggesting Enhancements | ||
|
||
Have an idea for an enhancement or a new feature for the Tokenguard Dashboard Builder Client? Feel free to share it by [opening an issue](https://github.com/tokenguardio/dashboard-creator-client/issues) on our GitHub repository. When suggesting enhancements, please provide: | ||
|
||
- A clear and descriptive title | ||
- Detailed description of the enhancement or feature request | ||
- Any relevant context or examples | ||
|
||
### Pull Requests | ||
|
||
We welcome pull requests from the community! If you'd like to contribute code to the Tokenguard Dashboard Builder Client, please follow these steps: | ||
|
||
1. Fork the repository and create your branch from `main`. | ||
2. Ensure that your code follows the project's coding style and conventions. | ||
3. Write tests for any new functionality and ensure existing tests pass. | ||
4. Make sure your commits are descriptive and follow best practices. | ||
5. Once you've finished your changes, submit a pull request to the `main` branch of the original repository. | ||
|
||
## License | ||
|
||
By contributing to the Tokenguard Dashboard Builder Client, you agree that your contributions will be licensed under the [MIT License](LICENSE) found in the root directory of this repository. | ||
|
||
Thank you for your contributions! |
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 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Tokenguard | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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 |
---|---|---|
@@ -1,185 +1,36 @@ | ||
# Node Express Template (NET.ts) with MongoDB | ||
### dashboard-creator-server | ||
|
||
The **N**ode **E**xpress **T**emplate (NET.ts) is a small template project which help you to speed up the process of building RESTful API. | ||
#### Tokenguard Dashboard Builder - Server | ||
|
||
Inside of this branch you will find fully configured and ready to use **express** based web application for **Node.js** runtime with document-oriented database **MongoDB**. | ||
Additionally, the **migrate-mongo** library is integrated to manage database migrations, enabling you to maintain a versioned history of crucial database changes. | ||
For more information on **mongo migrations** go here: https://github.com/przemek-nowicki/node-express-template.ts/blob/add_mongo/scripts/db/ | ||
Welcome to the Tokenguard Dashboard Builder Server repository! This repository contains the backend implementation of our dashboard builder tool for data analytics. The server-side application provides APIs for connecting frontend visualizations with underlying data, saving and modifying visualization-related data, and managing user dashboards. This tool is under constant development and its initial version was delivered thanks to Web3 Foundation [grant] (https://grants.web3.foundation/applications/Tokenguard) | ||
|
||
It’s built on **TypeScript** and follows the best **top-ranked** content on Node.js best practices from https://github.com/goldbergyoni/nodebestpractices repository. | ||
### Getting Started | ||
|
||
### Main features: | ||
To get started with the dashboard builder server, follow these steps: | ||
|
||
- 🐳 Containerized application | ||
- 🚄 [ExpressJS](http://expressjs.com) framework with [TypeScript](https://www.typescriptlang.org/) on the board | ||
- ♻️ Live reload | ||
- 🏇 minified and optimized code for production build | ||
- ✏️ Linting via [ESLint](https://eslint.org) with Airbnb configuration | ||
- 🚑 Code Formatter with [Prettier](https://prettier.io) | ||
- 📘 VSCode configuration: Debug, Settings, Tasks and extension for ESLint, Prettier, TypeScript | ||
- 🚧 Jest for unit testing | ||
- 🌐 **Mongo database** | ||
- 🏄 And many more... | ||
1. **Clone the Repository**: `git clone https://github.com/tokenguardio/dashboard-creator-server.git` | ||
2. **Install Dependencies**: `npm install` or `yarn install` | ||
3. **Run the Development Server**: `npm start` or `yarn start` | ||
|
||
Install `Docker` and `Docker Compose` which are used to maximise the convenience of development on local machine. | ||
### Features | ||
|
||
When both are installed, build the NET.ts image as follow: | ||
- **API Reading Mechanism**: Connect frontend visualizations with underlying data through a RESTful API built with NodeJS and Express. | ||
- **Data Storage**: Store visualization and dashboard-related data in MongoDB for efficient retrieval and management. | ||
- **Scalability**: Built with scalability in mind to handle large datasets and user traffic effectively. | ||
|
||
```sh | ||
docker-compose build | ||
``` | ||
### Tech Stack | ||
|
||
Run the app: | ||
- **Backend Framework**: NodeJS with Express | ||
- **Database**: MongoDB | ||
- **API Documentation**: OpenAPI | ||
- **Development Tool**: Docker | ||
|
||
```sh | ||
docker-compose up | ||
``` | ||
### Contributing | ||
|
||
Go to: | ||
We encourage contributions from the community! If you'd like to contribute to the Tokenguard Dashboard Builder Server, please refer to our [contribution guidelines](CONTRIBUTING.md) for more information. | ||
|
||
``` | ||
http://localhost:8080/api/health | ||
``` | ||
### License | ||
|
||
If you see the following response in the browser: | ||
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. | ||
|
||
``` | ||
{"status":"OK","data":"2022-02-13T20:05:13.965Z"} | ||
``` | ||
|
||
It means that everything work as expected. You may start to develop your business logic. | ||
Please scroll down to "How to work with NET.ts" section. | ||
|
||
## Getting started, standard way (no containerization) | ||
|
||
If you want to run NET.ts "standard way" using the `npm` instead of `docker-compose`. | ||
You are free to do it just keep in mind that I develop the NET.ts project on node version 16. | ||
Note: you need to set env variables defined in `.localhost.env` file. | ||
On mac OS you can use `export $(cat .localhost.env)` to export all env variables from the .localhost.env file. | ||
|
||
Install dependencies: | ||
|
||
``` | ||
npm install | ||
``` | ||
|
||
Run server in dev mode: | ||
|
||
``` | ||
npm run server:dev | ||
``` | ||
|
||
## How to work with NET.ts | ||
|
||
There are few rules that you have to obey to enjoy NET.ts fully. | ||
|
||
1. Enviromment variables - define your envs in `.localhost.env` file and provide validation rules for them inside `@config/config.ts` file. | ||
2. Structure your solution by components. There is an example [user](https://github.com/przemek-nowicki/node-express-template.ts/tree/master/src/components/user) CRUD component that shows how you may build logic for your own componnents. | ||
3. Define your routung inside `api.ts` fiile. | ||
4. Describe your newly created API inside `swagger.json` file | ||
|
||
## Testing | ||
|
||
The Jest test suites are run by executing | ||
|
||
```sh | ||
npm test | ||
``` | ||
|
||
To run tests directly insiide of the NET.ts container: | ||
|
||
```sh | ||
docker-compose run web npm run test | ||
``` | ||
|
||
## Code linting | ||
|
||
Run code quality analysis using | ||
|
||
```sh | ||
npm run lint | ||
``` | ||
|
||
or insde of the container | ||
|
||
```sh | ||
docker-compose run web npm run lint | ||
``` | ||
|
||
## Fixing problems | ||
|
||
Automatically fix linter's problems | ||
|
||
```sh | ||
npm run lint:fix | ||
``` | ||
|
||
or insde of the container | ||
|
||
```sh | ||
docker-compose run web npm run lint:fix | ||
``` | ||
|
||
## Logging | ||
|
||
```javascript | ||
import logger from '@core/utils/logger'; | ||
|
||
logger.error('message'); // level 0 | ||
logger.warn('message'); // level 1 | ||
logger.info('message'); // level 2 | ||
logger.http('message'); // level 3 | ||
logger.verbose('message'); // level 4 | ||
logger.debug('message'); // level 5 | ||
logger.silly('message'); // level 6 | ||
``` | ||
|
||
In development mode, log messages of all severity levels will be printed to the console. | ||
In production mode, only `info`, `warn`, and `error` logs will be printed to the console. | ||
|
||
Note: API request information (request url, response code, timestamp, etc.) are also automatically logged (using [morgan](https://github.com/expressjs/morgan)). | ||
|
||
### Switching log-level on runtime | ||
|
||
If you use docker to run the app, please connect to `node-express-template_web*` container and simply execute `npm run loglevel:change` in new terminal. It will increase your current log level, in case you reach the highest level it will back to error level which is 0. | ||
This feature may be useful on production env when you want to switch your app log level to debug without restarting node server. | ||
|
||
## Troubleshooting | ||
|
||
To help you diagnose problems, a Unique Request ID is added to each incoming request and printed to a log. This allows you to correlate log entries for a given web request across multiple log data sources. | ||
|
||
Here are some examples of log entries for a Create User request (/api/user): | ||
|
||
```log | ||
web_1 | 2022-12-18 09:56:51 8e06413b-1cbb-41d4-baf3-01ee12b94602 info START Request Id: 8e06413b-1cbb-41d4-baf3-01ee12b94602 | ||
web_1 | 2022-12-18 09:56:51 8e06413b-1cbb-41d4-baf3-01ee12b94602 debug User created: { name: 'John Doe', email: '[email protected]' } | ||
web_1 | 2022-12-18 09:56:51 8e06413b-1cbb-41d4-baf3-01ee12b94602 info POST /api/user 201 - 145.525 ms | ||
web_1 | 2022-12-18 09:56:51 8e06413b-1cbb-41d4-baf3-01ee12b94602 info END Request Id: 8e06413b-1cbb-41d4-baf3-01ee12b94602 | ||
``` | ||
|
||
## SwaggerUI | ||
|
||
An interactive API documentation of NET.ts can be accessed at the path: <baseURL>/api-docs \ | ||
For local development use this: http://localhost:8080/api-docs \ | ||
If your webservice's basePath is different from `"/"` put basePath after `api-docs` in url address e.g. \ | ||
for service placed under `<basePath>` subfolder the correct URL is: `https://<baseURL>/<basePath>/api-docs/<basePath>` \ | ||
Remember to select correct protocol befor you try to call any endpoint, "http" is used only for local development. \ | ||
Important: swaggerUI is disabled for the production env | ||
|
||
## Running in production with Docker | ||
|
||
For the sake of readability, you may build an image with custom name i.e. **net.ts**, go to the root project (where the Dockerfile is) and execute: | ||
|
||
`docker build -t net.ts .` | ||
|
||
When done, execute the docker run command to create a container from a net.ts image and starts the container with all the required environment variables: | ||
|
||
`docker run --rm -it -e NODE_ENV='production' -e API_KEY_TOKEN='token' -p 8080:8080 net.ts` | ||
|
||
That's it, you just ran the app in production mode. | ||
|
||
## Contributing | ||
|
||
All contributions are welcome! | ||
|
||
🙌 Thanks | ||
--- |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.