Skip to content

Commit

Permalink
Minor refactor, add typings (#154)
Browse files Browse the repository at this point in the history
* use lint and test as pre commit scripts

* separate linting from testing
move tap configuration int

* add typings
  • Loading branch information
Uzlopak authored Aug 8, 2022
1 parent 8cbd84c commit 71bdcae
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 11 deletions.
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' });

0 comments on commit 71bdcae

Please sign in to comment.