Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v4 #535

Open
wants to merge 21 commits into
base: next
Choose a base branch
from
Open

v4 #535

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 0 additions & 40 deletions .github/workflows/cd.yml

This file was deleted.

97 changes: 97 additions & 0 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: CI/CD

on:
push:
pull_request:
types: [opened, reopened]

env:
FORCE_COLOR: 3 # Diplay chalk colors

jobs:
ci:
name: Integration
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b
- uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d
with:
version: 9
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8
with:
node-version: lts/*
cache: pnpm
# Generate local TLS certificates to test HTTPS support, using mkcert:
- name: Install dependencies
run: pnpm install
- name: Install & setup mkcert
run: |
sudo apt install libnss3-tools
curl -JLO "https://dl.filippo.io/mkcert/latest?for=linux/amd64"
chmod +x mkcert-v*-linux-amd64
sudo cp mkcert-v*-linux-amd64 /usr/local/bin/mkcert
echo "mkcert version: $(mkcert -version)"
mkcert -install
- name: Generate TLS certificates
run: pnpm mkcert
- name: Run integration tests
run: pnpm run ci
- uses: coverallsapp/github-action@3dfc5567390f6fa9267c0ee9c251e4c8c3f18949
name: Report code coverage
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- uses: 47ng/actions-slack-notify@main
name: Notify on Slack
if: always()
with:
jobName: Integration
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

cd:
name: Deployment
runs-on: ubuntu-latest
needs: [ci]
if: ${{ github.ref_name == 'main' || github.ref_name == 'beta' || github.ref_name == 'alpha' }}
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b
- uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d
with:
version: 9
run_install: |
- args: [--frozen-lockfile]
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8
with:
node-version: lts/*
cache: pnpm
- name: Install dependencies
run: pnpm install --ignore-scripts --frozen-lockfile
- name: Build package
run: pnpm build
- name: Sign package
run: npx sceau sign
env:
SCEAU_BUILD_URL: https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
SCEAU_SOURCE_URL: https://github.com/${{github.repository}}/commit/${{ github.sha }}
SCEAU_PRIVATE_KEY: ${{ secrets.SCEAU_PRIVATE_KEY }}
- uses: docker://ghcr.io/codfish/semantic-release-action@sha256:16ab6c16b1bff6bebdbcc6cfc07dfafff49d23c6818490500b8edb3babfff29e
name: Semantic Release
id: semantic
with:
branches: |
[
'main',
{
name: 'beta',
prerelease: true
},
{
name: 'alpha',
prerelease: true
}
]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
45 changes: 0 additions & 45 deletions .github/workflows/ci.yml

This file was deleted.

5 changes: 1 addition & 4 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn commitlint --edit $1
pnpm commitlint --edit $1
4 changes: 0 additions & 4 deletions .husky/pre-push

This file was deleted.

11 changes: 0 additions & 11 deletions .npmignore

This file was deleted.

1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
enable-pre-post-scripts=true
35 changes: 30 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

[![NPM](https://img.shields.io/npm/v/fastify-micro?color=red)](https://www.npmjs.com/package/fastify-micro)
[![MIT License](https://img.shields.io/github/license/47ng/fastify-micro.svg?color=blue)](https://github.com/47ng/fastify-micro/blob/master/LICENSE)
[![Continuous Integration](https://github.com/47ng/fastify-micro/workflows/Continuous%20Integration/badge.svg?branch=next)](https://github.com/47ng/fastify-micro/actions)
[![CI/CD](https://github.com/47ng/fastify-micro/workflows/CI%2FCD/badge.svg?branch=next)](https://github.com/47ng/fastify-micro/actions)
[![Coverage Status](https://coveralls.io/repos/github/47ng/fastify-micro/badge.svg?branch=next)](https://coveralls.io/github/47ng/fastify-micro?branch=next)

</div>
Expand All @@ -25,8 +25,8 @@
## Installation

```shell
$ pnpm add fastify-micro
$ yarn add fastify-micro
# or
$ npm i fastify-micro
```

Expand Down Expand Up @@ -491,10 +491,35 @@ createServer({
If for some reason you wish to disable service health monitoring, you can set
the `FASTIFY_MICRO_DISABLE_SERVICE_HEALTH_MONITORING` environment variable to `true`.

## Deprecated APIs
## HTTPS

- `configure` _(will be removed in v4.x)_: Use `plugins` with full `fastify-autoload` options.
- `routesDir` _(will be removed in v4.x)_: Use `routes` with full `fastify-autoload` options.
You can enable HTTPS by passing a TLS configuration to the [`https`](https://nodejs.org/dist/latest-v14.x/docs/api/https.html#https_https_createserver_options_requestlistener) option:

```ts
import fs from 'node:fs/promises'

createServer({
https: {
cert: await fs.readFile('path/to/my/cert.pem'),
key: await fs.readFile('path/to/my/cert-key.pem')
}
})
```

> **Note**: if you wish to run unit tests locally, you'll need certificates
> to run the HTTPS tests.
>
> Install [`mkcert`](https://github.com/FiloSottile/mkcert) on your machine,
> then run `pnpm mkcert` to generate them.

## Code signature

This package is signed with [`sceau`](https://github.com/47ng/sceau).
You can verify its signature against the following public key:

```shell
sceau verify --publicKey 4375fc7bacb2f0a931d3a50367ad79f6562f600aad9dd83545544d9c0b2dc7d3
```

## License

Expand Down
1 change: 1 addition & 0 deletions certs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.pem
102 changes: 67 additions & 35 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
"name": "fastify-micro",
"version": "0.0.0-semantically-released",
"description": "Opinionated Node.js microservices framework built on fastify",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"license": "MIT",
"author": {
"name": "François Best",
Expand All @@ -21,51 +19,85 @@
"publishConfig": {
"access": "public"
},
"files": [
"dist/",
"sceau.json",
".env.example"
],
"type": "module",
"sideEffects": false,
"module": "dist/index.js",
"types": "dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
},
"./env": {
"types": "./dist/env.d.ts",
"import": "./dist/env.js"
}
},
"scripts": {
"test": "jest --coverage --runInBand",
"test:watch": "jest --watch --runInBand",
"build:clean": "rm -rf ./dist",
"build:ts": "tsc",
"build": "run-s build:clean build:ts",
"ci": "run-s build test",
"test": "NODE_EXTRA_CA_CERTS=\"$(mkcert -CAROOT)/rootCA.pem\" vitest run --coverage",
"test:watch": "NODE_EXTRA_CA_CERTS=\"$(mkcert -CAROOT)/rootCA.pem\" vitest",
"prebuild": "rm -rf ./dist && mkdir -p ./dist",
"build": "run-p build:*",
"build:bundle": "tsup",
"build:copy-worker": "cp -f ./src/logRedactionWorker.mjs ./dist/",
"ci": "run-p build test",
"test:integration": "NODE_ENV=production ts-node ./tests/integration/main.ts",
"prepare": "husky install"
"prepare": "husky",
"mkcert": "mkcert -cert-file ./certs/fastify-micro.localhost.pem -key-file ./certs/fastify-micro.localhost-key.pem fastify-micro.localhost localhost 127.0.0.1 ::1"
},
"peerDependencies": {
"fastify": "^4",
"pino": "^8 || ^9"
},
"dependencies": {
"@47ng/check-env": "^2.1.0",
"@sentry/node": "^6.18.1",
"fastify": "^3.27.2",
"fastify-autoload": "^3.11.0",
"fastify-plugin": "^3.0.1",
"fastify-sensible": "^3.1.2",
"get-port": "^6.1.2",
"nanoid": "^3.3.1",
"redact-env": "^0.3.1",
"sonic-boom": "^2.6.0",
"under-pressure": "^5.8.0"
"@fastify/autoload": "^5.8.2",
"@fastify/sensible": "^5.6.0",
"@fastify/under-pressure": "^8.3.0",
"@sentry/node": "^7.113.0",
"@t3-oss/env-core": "^0.10.1",
"fastify-plugin": "^4.5.1",
"pino-abstract-transport": "^1.2.0",
"redact-env": "^1.0.0",
"sonic-boom": "^4.0.1",
"zod": "^3.23.6"
},
"devDependencies": {
"@commitlint/config-conventional": "^16.2.1",
"@types/jest": "^27.4.1",
"@types/node": "^17.0.21",
"@types/pino": "7.0.5",
"@types/sonic-boom": "^2.1.1",
"axios": "^0.26.0",
"commitlint": "^16.2.1",
"husky": "^7.0.4",
"jest": "^27.5.1",
"@commitlint/config-conventional": "^19.2.2",
"@types/node": "^20.12.10",
"@vitest/coverage-v8": "^1.6.0",
"commitlint": "^19.3.0",
"fastify": "^4.27.0",
"husky": "^9.0.11",
"npm-run-all": "^4.1.5",
"regenerator-runtime": "^0.13.9",
"sentry-testkit": "^3.3.7",
"ts-jest": "^27.1.3",
"ts-node": "^10.6.0",
"typescript": "^4.6.2",
"pino": "^9.0.0",
"redaxios": "^0.5.1",
"sceau": "^1.3.0",
"sentry-testkit": "^5.0.9",
"tsup": "^8.0.2",
"tsx": "^4.9.3",
"typescript": "^5.4.5",
"vitest": "^1.6.0",
"wait-for-expect": "^3.0.2"
},
"engines": {
"node": ">=20"
},
"jest": {
"verbose": true,
"preset": "ts-jest/presets/js-with-ts",
"transform": {
"^.+\\.(t|j)sx?$": [
"@swc/jest"
]
},
"testEnvironment": "node",
"testMatch": [
"<rootDir>/tests/**/*.test.ts"
],
"testPathIgnorePatterns": [
"/node_modules/",
"<rootDir>/tests/integration/"
Expand Down
Loading
Loading