Skip to content

Commit

Permalink
build(deps-dev): replace standard with neostandard (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fdawgs authored Dec 5, 2024
1 parent 2b438dd commit 32d1844
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

![CI](https://github.com/fastify/fastify-basic-auth/workflows/CI/badge.svg?branch=master)
[![NPM version](https://img.shields.io/npm/v/@fastify/basic-auth.svg?style=flat)](https://www.npmjs.com/package/@fastify/basic-auth)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://standardjs.com/)
[![neostandard javascript style](https://img.shields.io/badge/code_style-neostandard-brightgreen?style=flat)](https://github.com/neostandard/neostandard)

A simple basic auth plugin for Fastify.

Expand Down
6 changes: 6 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
'use strict'

module.exports = require('neostandard')({
ignores: require('neostandard').resolveIgnoresFromGitignore(),
ts: true
})
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"type": "commonjs",
"types": "types/index.d.ts",
"scripts": {
"lint": "standard",
"lint": "eslint",
"lint:fix": "eslint --fix",
"test": "npm run test:unit && npm run test:types",
"test:unit": "c8 --100 node --test",
"test:types": "tsd"
Expand Down Expand Up @@ -34,7 +35,7 @@
"@types/node": "^22.0.0",
"c8": "^10.1.2",
"fastify": "^5.0.0",
"standard": "^17.1.0",
"neostandard": "^0.11.9",
"tsd": "^0.31.1"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ declare namespace fastifyBasicAuth {
export { fastifyBasicAuth as default }
}

declare function fastifyBasicAuth(...params: Parameters<FastifyBasicAuth>): ReturnType<FastifyBasicAuth>
declare function fastifyBasicAuth (...params: Parameters<FastifyBasicAuth>): ReturnType<FastifyBasicAuth>
export = fastifyBasicAuth
20 changes: 11 additions & 9 deletions types/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import fastifyBasicAuth from '..'

const app = fastify()

//validation ok
// validation ok
app.register(fastifyBasicAuth, {
validate: async function validatePromise (username, password, req, reply) {
expectType<string>(username)
Expand All @@ -23,15 +23,15 @@ app.register(fastifyBasicAuth, {
header: 'x-forwarded-authorization'
})

//validation failure
// validation failure
app.register(fastifyBasicAuth, {
validate: async function validatePromise (username, password, req, reply) {
expectType<string>(username)
expectType<string>(password)
expectType<FastifyRequest>(req)
expectType<FastifyReply>(reply)
expectType<FastifyInstance>(this)
return new Error("unauthorized")
return new Error('unauthorized')
},
header: 'x-forwarded-authorization'
})
Expand All @@ -47,24 +47,26 @@ app.register(fastifyBasicAuth, {
}
})

//authenticate boolean
// authenticate boolean
app.register(fastifyBasicAuth, {
validate: () => {},
authenticate: true
})

//authenticate with realm
// authenticate with realm
app.register(fastifyBasicAuth, {
validate: () => {},
authenticate: { realm: 'example' }
})

//authenticate with realm (function)
// authenticate with realm (function)
app.register(fastifyBasicAuth, {
validate: () => {},
authenticate: { realm: function realm(req) {
return req.url
}}
authenticate: {
realm: function realm (req) {
return req.url
}
}
})

app.register(fastifyBasicAuth, {
Expand Down

0 comments on commit 32d1844

Please sign in to comment.