Skip to content

Commit

Permalink
chore: rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
Fdawgs committed Dec 16, 2024
1 parent 93ae3f0 commit 385f85c
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 35 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"cross-env": "^7.0.3",
"fastify-tsconfig": "^2.0.0",
"minimatch": "^9.0.5",
"neostandard": "^0.11.9",
"neostandard": "^0.12.0",
"proxyquire": "^2.1.3",
"rimraf": "^3.0.2",
"simple-get": "^4.0.0",
Expand Down
6 changes: 3 additions & 3 deletions templates/app-ts-esm/src/app.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as path from 'node:path';
import AutoLoad, {AutoloadPluginOptions} from '@fastify/autoload';
import { FastifyPluginAsync } from 'fastify';
import * as path from 'node:path'
import AutoLoad, { AutoloadPluginOptions } from '@fastify/autoload'
import { FastifyPluginAsync } from 'fastify'
import { fileURLToPath } from 'node:url'

const __filename = fileURLToPath(import.meta.url)
Expand Down
6 changes: 3 additions & 3 deletions templates/app-ts/src/app.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { join } from 'node:path';
import AutoLoad, {AutoloadPluginOptions} from '@fastify/autoload';
import { FastifyPluginAsync, FastifyServerOptions } from 'fastify';
import { join } from 'node:path'
import AutoLoad, { AutoloadPluginOptions } from '@fastify/autoload'
import { FastifyPluginAsync, FastifyServerOptions } from 'fastify'

export interface AppOptions extends FastifyServerOptions, Partial<AutoloadPluginOptions> {

Expand Down
2 changes: 1 addition & 1 deletion templates/app-ts/test/helper.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// This file contains code that we reuse between our tests.
const helper = require('fastify-cli/helper.js')
import * as path from 'node:path'
import * as test from 'node:test'
const helper = require('fastify-cli/helper.js')

export type TestContext = {
after: typeof test.after
Expand Down
2 changes: 1 addition & 1 deletion templates/eject-ts/server.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Read the .env file.
import * as dotenv from 'dotenv'
dotenv.config()

// Require the framework
import Fastify from 'fastify'

// Require library to exit fastify process, gracefully (if possible)
import closeWithGrace from 'close-with-grace'
dotenv.config()

// Instantiate Fastify with some config
const app = Fastify({
Expand Down
52 changes: 26 additions & 26 deletions test/templates/app-ts.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { fastify } from 'fastify';
import { test, TestContext } from 'node:test';
const sgetOriginal = require('simple-get').concat
import { fastify } from 'fastify'
import { test, TestContext } from 'node:test'

import { AddressInfo } from "net";
import appDefault, { app } from '../../templates/app-ts/src/app';
import { AddressInfo } from 'net'
import appDefault, { app } from '../../templates/app-ts/src/app'
const sgetOriginal = require('simple-get').concat

const sget = (opts: Record<string, any>): Record<string, any> => {
return new Promise((resolve, reject) => {
Expand All @@ -14,42 +14,42 @@ const sget = (opts: Record<string, any>): Record<string, any> => {
})
}

test('should print routes for TS app', async (t: TestContext) => {
t.plan(4)
test('should print routes for TS app', async (t: TestContext) => {
t.plan(4)

const fastifyApp = fastify({})
await app(fastifyApp, {})
await fastifyApp.ready()
await fastifyApp.listen({ port: 3000 })

const { response, body } = await sget({
method: 'GET',
url: `http://localhost:${(fastifyApp.server.address() as AddressInfo).port}`
})
t.assert.equal(response.statusCode, 200)
t.assert.equal(response.headers['content-length'], '' + body.length)
t.assert.deepStrictEqual(JSON.parse(body), { root: true })
const { response, body } = await sget({
method: 'GET',
url: `http://localhost:${(fastifyApp.server.address() as AddressInfo).port}`
})
t.assert.equal(response.statusCode, 200)
t.assert.equal(response.headers['content-length'], '' + body.length)
t.assert.deepStrictEqual(JSON.parse(body), { root: true })

await fastifyApp.close();
t.assert.ok('server closed')
await fastifyApp.close()
t.assert.ok('server closed')
})

test('should print routes for default TS app', async (t: TestContext) => {
t.plan(4)
t.plan(4)

const fastifyApp = fastify({})
await appDefault(fastifyApp, {})
await fastifyApp.ready()
await fastifyApp.listen({ port: 3000 })

const { response, body } = await sget({
method: 'GET',
url: `http://localhost:${(fastifyApp.server.address() as AddressInfo).port}`
})
t.assert.equal(response.statusCode, 200)
t.assert.equal(response.headers['content-length'], '' + body.length)
t.assert.deepStrictEqual(JSON.parse(body), { root: true })
const { response, body } = await sget({
method: 'GET',
url: `http://localhost:${(fastifyApp.server.address() as AddressInfo).port}`
})
t.assert.equal(response.statusCode, 200)
t.assert.equal(response.headers['content-length'], '' + body.length)
t.assert.deepStrictEqual(JSON.parse(body), { root: true })

await fastifyApp.close();
t.assert.ok('server closed')
await fastifyApp.close()
t.assert.ok('server closed')
})

0 comments on commit 385f85c

Please sign in to comment.