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

perf: use node: prefix to bypass require.cache call for builtins #85

Merged
merged 2 commits into from
Sep 10, 2023
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: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ Here is an example using the [`@fastify/basic-auth`](https://github.com/fastify/
##### Example
```js
const fastify = require('fastify')()
const crypto = require('crypto')
const crypto = require('node:crypto')

fastify.register(require('@fastify/swagger'))

Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict'

const fp = require('fastify-plugin')
const { readFile } = require('fs/promises')
const path = require('path')
const { readFile } = require('node:fs/promises')
const path = require('node:path')

async function fastifySwaggerUi (fastify, opts) {
fastify.decorate('swaggerCSP', require('./static/csp.json'))
Expand Down
2 changes: 1 addition & 1 deletion lib/routes.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const path = require('path')
const path = require('node:path')
const yaml = require('yaml')
const fastifyStatic = require('@fastify/static')
const rfdc = require('rfdc')()
Expand Down
6 changes: 3 additions & 3 deletions scripts/prepare-swagger-ui.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const fs = require('fs')
const fs = require('node:fs')
const fse = require('fs-extra')
const crypto = require('crypto')
const crypto = require('node:crypto')
const swaggerUiAssetPath = require('swagger-ui-dist').getAbsoluteFSPath()
const resolve = require('path').resolve
const resolve = require('node:path').resolve

const folderName = 'static'

Expand Down
4 changes: 2 additions & 2 deletions test/route.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ const {
swaggerOption
} = require('../examples/options')

const resolve = require('path').resolve
const readFileSync = require('fs').readFileSync
const resolve = require('node:path').resolve
const readFileSync = require('node:fs').readFileSync

const schemaParamsWithoutDesc = {
schema: {
Expand Down
4 changes: 2 additions & 2 deletions test/static.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ const Fastify = require('fastify')
const fastifySwagger = require('@fastify/swagger')
const fastifySwaggerUi = require('../index')
const yaml = require('yaml')
const readFileSync = require('fs').readFileSync
const resolve = require('path').resolve
const readFileSync = require('node:fs').readFileSync
const resolve = require('node:path').resolve

test('swagger route returns yaml', async (t) => {
const config = {
Expand Down