Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lissone/node-fastify-knex
Simple Node Fastify API using Knex with SQLite and tests.
https://github.com/lissone/node-fastify-knex
eslint fastify knex nodejs sqlite3 supertest typescript vitest zod
Last synced: about 1 month ago
JSON representation
Simple Node Fastify API using Knex with SQLite and tests.
- Host: GitHub
- URL: https://github.com/lissone/node-fastify-knex
- Owner: Lissone
- Created: 2024-04-23T21:54:30.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-08-21T00:40:36.000Z (4 months ago)
- Last Synced: 2024-08-21T01:58:49.503Z (4 months ago)
- Topics: eslint, fastify, knex, nodejs, sqlite3, supertest, typescript, vitest, zod
- Language: TypeScript
- Homepage:
- Size: 145 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Simple Node Fastify API using Knex
Description |
Requirements |
Technologies |
Usage
## Description
This project was developed with the goal of exploring and learning how to use the Fastify library for creating APIs with Node.js, as well as getting familiar with Knex as a query builder to interact with databases. I also took the opportunity to practice and solidify my knowledge in testing.
### Functional Requirements
- [x] The user must be able to create a new transaction;
- [x] The user must be able to get a summary of their account;
- [x] The user must be able to list all transactions that have occurred;
- [x] The user must be able to view a single transaction.### Business Rules
- [x] The transaction can be of the credit type, which will add to the total amount, or debit, which will subtract;
- [x] It must be possible to identify the user among the requests;
- [x] The user can only view transactions they have created.### About Tests
- Unit: unit of your application;
- Integration: communication between two or more units;
- E2E: simulate a user operating in our application.Test pyramid: E2E does not depend on any technology, nor on architecture.
## Requirements
- [Npm](https://www.npmjs.com/)
- [Yarn](https://yarnpkg.com/)
- [Nodejs](https://nodejs.org/en/)## Technologies
- Nodejs
- Typescript
- Fastify
- Knex
- Sqlite3
- Zod
- Vitest
- Supertest
- Eslint
- @rockeseat/eslint-config
- Prettier## Usage
You can clone it on your pc using the command:
```bash
git clone https://github.com/Lissone/node-fastify-knex.git
cd node-fastify-knex
```### Run migrations
You need to run a knex script command to run all current migrations:
```bash
npm run knex -- migrate:latest
```About more knex commands:
```bash
# List knex help
npm run knex -- -help
# Create a migration
npm run knex -- migrate:make
```### Add environment variables
```bash
# .\.envNODE_ENV=development
DATABASE_URL="./db/app.db"
```### Install dependencies
```bash
yarn
#or
npm install
```### Run project
```bash
yarn start:dev
#or
npm run start:dev
```## License
Distributed under the MIT License. See `LICENSE` for more information.