-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build(deps-dev): replace standard with neostandard (#157)
- Loading branch information
Showing
5 changed files
with
47 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,69 @@ | ||
import Fastify, { FastifyReply } from 'fastify'; | ||
import { expectAssignable, expectError, expectType } from 'tsd'; | ||
import Fastify, { FastifyReply } from 'fastify' | ||
import { expectAssignable, expectError, expectType } from 'tsd' | ||
import fastifyCaching, { | ||
AbstractCacheCompliantObject, | ||
FastifyCachingPluginOptions, | ||
} from '..'; | ||
} from '..' | ||
|
||
const fastify = Fastify({ logger: true }); | ||
const fastify = Fastify({ logger: true }) | ||
|
||
const cachingOptions: FastifyCachingPluginOptions = { | ||
privacy: fastifyCaching.privacy.PUBLIC, | ||
expiresIn: 300, | ||
cacheSegment: 'fastify-caching', | ||
}; | ||
expectAssignable<FastifyCachingPluginOptions>(cachingOptions); | ||
} | ||
expectAssignable<FastifyCachingPluginOptions>(cachingOptions) | ||
|
||
fastify.register(fastifyCaching, cachingOptions); | ||
fastify.register(fastifyCaching, cachingOptions) | ||
|
||
expectType<AbstractCacheCompliantObject>(fastify.cache); | ||
expectType<AbstractCacheCompliantObject['get']>(fastify.cache.get); | ||
expectType<AbstractCacheCompliantObject['set']>(fastify.cache.set); | ||
expectType<string>(fastify.cacheSegment); | ||
expectType<AbstractCacheCompliantObject>(fastify.cache) | ||
expectType<AbstractCacheCompliantObject['get']>(fastify.cache.get) | ||
expectType<AbstractCacheCompliantObject['set']>(fastify.cache.set) | ||
expectType<string>(fastify.cacheSegment) | ||
// expectType<number>(fastify.etagMaxLife); | ||
|
||
fastify.get('/one', async (request, reply) => { | ||
expectType<(tag?: string, timeToLive?: number) => FastifyReply>(reply.etag); | ||
expectType<(date?: Date) => FastifyReply>(reply.expires); | ||
expectType<(tag?: string, timeToLive?: number) => FastifyReply>(reply.etag) | ||
expectType<(date?: Date) => FastifyReply>(reply.expires) | ||
|
||
expectType<FastifyReply>(reply.etag('hello', 6000)); | ||
expectType<FastifyReply>(reply.expires(new Date(Date.now() + 6000))); | ||
expectType<FastifyReply>(reply.etag('hello', 6000)) | ||
expectType<FastifyReply>(reply.expires(new Date(Date.now() + 6000))) | ||
|
||
return { message: 'one' }; | ||
}); | ||
return { message: 'one' } | ||
}) | ||
|
||
fastify.get('/two', async (request, reply) => { | ||
expectType<FastifyReply>( | ||
reply.etag('hello', 6000).expires(new Date(Date.now() + 6000)) | ||
); | ||
) | ||
|
||
return { message: 'two' }; | ||
}); | ||
return { message: 'two' } | ||
}) | ||
|
||
// We register a new instance that should trigger a typescript error. | ||
const shouldErrorApp = Fastify({ logger: true }); | ||
const shouldErrorApp = Fastify({ logger: true }) | ||
|
||
const badCachingOptions = { | ||
privacy: fastifyCaching.privacy.PRIVATE, | ||
expiresIn: 'a string instead of a number of second', | ||
cacheSegment: 'fastify-caching', | ||
}; | ||
} | ||
|
||
expectError(shouldErrorApp.register(fastifyCaching, badCachingOptions)); | ||
expectError(shouldErrorApp.register(fastifyCaching, badCachingOptions)) | ||
|
||
fastify.get('/three', async (request, reply) => { | ||
expectAssignable<Promise<unknown>>( | ||
fastify.cache.get('well-known') | ||
); | ||
) | ||
expectAssignable<Promise<{ item: string; stored: number; ttl: number; } | null>>( | ||
fastify.cache.get<string>('well-known') | ||
); | ||
) | ||
expectType<void>( | ||
fastify.cache.get<string>('well-known', (err, value) => { | ||
expectType<unknown>(err); | ||
expectAssignable<{ item: string; stored: number; ttl: number; } | null>(value); | ||
expectType<unknown>(err) | ||
expectAssignable<{ item: string; stored: number; ttl: number; } | null>(value) | ||
}) | ||
); | ||
) | ||
|
||
return { message: 'two' }; | ||
}); | ||
return { message: 'two' } | ||
}) |