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

Minor refactor, add typings #154

Merged
merged 3 commits into from
Aug 8, 2022
Merged
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
2 changes: 2 additions & 0 deletions .taprc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
files:
- test/**.test.js
7 changes: 0 additions & 7 deletions index.d.ts

This file was deleted.

13 changes: 9 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
"version": "4.0.0",
"description": "Fastify plugin to check environment variables",
"main": "index.js",
"types": "types/index.d.ts",
"scripts": {
"coverage": "cross-env VALUE_FROM_ENV=pippo tap --cov --coverage-report=html test/*.js",
"coverage": "cross-env VALUE_FROM_ENV=pippo tap --cov --coverage-report=html",
"lint": "standard | snazzy",
"lint:fix": "standard --fix",
"test": "npm run lint && npm run unit && npm run typescript",
"typescript": "tsd",
"unit": "cross-env VALUE_FROM_ENV=pippo tap test/*.js"
"test": "npm run test:unit && npm run test:typescript",
"test:typescript": "tsd",
"test:unit": "cross-env VALUE_FROM_ENV=pippo tap"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -38,6 +39,10 @@
"tap": "^16.0.0",
"tsd": "^0.22.0"
},
"pre-commit": [
"lint",
"test"
],
"tsd": {
"directory": "test/types"
},
Expand Down
7 changes: 7 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { EnvSchemaOpt } from "env-schema";
import { FastifyPluginCallback } from "fastify";

export type fastifyEnvOpt = EnvSchemaOpt & { confKey?: string };

export const fastifyEnv: FastifyPluginCallback<fastifyEnvOpt>;
export default fastifyEnv;
6 changes: 6 additions & 0 deletions types/index.test-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import fastify from 'fastify';
import fastifyEnv from '..';

const server = fastify();

server.register(fastifyEnv, { confKey: 'test' });