@prairielearn/express-test-utils 2.0.0 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @prairielearn/express-test-utils
2
2
 
3
+ ## 2.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 678b48a: Upgrade all JavaScript dependencies
8
+
9
+ ## 2.0.1
10
+
11
+ ### Patch Changes
12
+
13
+ - d97b97a: Upgrade all JavaScript dependencies
14
+
3
15
  ## 2.0.0
4
16
 
5
17
  ### Major Changes
package/dist/index.d.ts CHANGED
@@ -1,9 +1,8 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- import * as express from 'express';
3
- import { Server } from 'node:http';
1
+ import { type Server } from 'node:http';
2
+ import { type Express } from 'express';
4
3
  export interface WithServerContext {
5
4
  server: Server;
6
5
  port: number;
7
6
  url: string;
8
7
  }
9
- export declare function withServer(app: express.Express, fn: (ctx: WithServerContext) => Promise<void>): Promise<void>;
8
+ export declare function withServer(app: Express, fn: (ctx: WithServerContext) => Promise<void>): Promise<void>;
package/dist/index.js CHANGED
@@ -1,3 +1,5 @@
1
+ import {} from 'node:http';
2
+ import {} from 'express';
1
3
  export async function withServer(app, fn) {
2
4
  const server = app.listen();
3
5
  await new Promise((resolve, reject) => {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,GAAoB,EACpB,EAA6C;IAE7C,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC;IAE5B,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC1C,MAAM,CAAC,EAAE,CAAC,WAAW,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;QACxC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC;QACH,MAAM,EAAE,CAAC;YACP,MAAM;YACN,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC;YAC3B,GAAG,EAAE,oBAAoB,aAAa,CAAC,MAAM,CAAC,EAAE;SACjD,CAAC,CAAC;IACL,CAAC;YAAS,CAAC;QACT,MAAM,CAAC,KAAK,EAAE,CAAC;IACjB,CAAC;AACH,CAAC;AAED,SAAS,aAAa,CAAC,MAAc;IACnC,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;IAEjC,uBAAuB;IACvB,IAAI,CAAC,OAAO;QAAE,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAEzD,uBAAuB;IACvB,IAAI,OAAO,OAAO,KAAK,QAAQ;QAAE,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;IAElF,OAAO,OAAO,CAAC,IAAI,CAAC;AACtB,CAAC","sourcesContent":["import * as express from 'express';\nimport { Server } from 'node:http';\n\nexport interface WithServerContext {\n server: Server;\n port: number;\n url: string;\n}\n\nexport async function withServer(\n app: express.Express,\n fn: (ctx: WithServerContext) => Promise<void>,\n) {\n const server = app.listen();\n\n await new Promise<void>((resolve, reject) => {\n server.on('listening', () => resolve());\n server.on('error', (err) => reject(err));\n });\n\n try {\n await fn({\n server,\n port: getServerPort(server),\n url: `http://localhost:${getServerPort(server)}`,\n });\n } finally {\n server.close();\n }\n}\n\nfunction getServerPort(server: Server): number {\n const address = server.address();\n\n // istanbul ignore next\n if (!address) throw new Error('Server is not listening');\n\n // istanbul ignore next\n if (typeof address === 'string') throw new Error('Server is listening on a pipe');\n\n return address.port;\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,MAAM,WAAW,CAAC;AAExC,OAAO,EAAgB,MAAM,SAAS,CAAC;AAQvC,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,GAAY,EAAE,EAA6C;IAC1F,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC;IAE5B,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC1C,MAAM,CAAC,EAAE,CAAC,WAAW,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;QACxC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC;QACH,MAAM,EAAE,CAAC;YACP,MAAM;YACN,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC;YAC3B,GAAG,EAAE,oBAAoB,aAAa,CAAC,MAAM,CAAC,EAAE;SACjD,CAAC,CAAC;IACL,CAAC;YAAS,CAAC;QACT,MAAM,CAAC,KAAK,EAAE,CAAC;IACjB,CAAC;AACH,CAAC;AAED,SAAS,aAAa,CAAC,MAAc;IACnC,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;IAEjC,uBAAuB;IACvB,IAAI,CAAC,OAAO;QAAE,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAEzD,uBAAuB;IACvB,IAAI,OAAO,OAAO,KAAK,QAAQ;QAAE,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;IAElF,OAAO,OAAO,CAAC,IAAI,CAAC;AACtB,CAAC","sourcesContent":["import { type Server } from 'node:http';\n\nimport { type Express } from 'express';\n\nexport interface WithServerContext {\n server: Server;\n port: number;\n url: string;\n}\n\nexport async function withServer(app: Express, fn: (ctx: WithServerContext) => Promise<void>) {\n const server = app.listen();\n\n await new Promise<void>((resolve, reject) => {\n server.on('listening', () => resolve());\n server.on('error', (err) => reject(err));\n });\n\n try {\n await fn({\n server,\n port: getServerPort(server),\n url: `http://localhost:${getServerPort(server)}`,\n });\n } finally {\n server.close();\n }\n}\n\nfunction getServerPort(server: Server): number {\n const address = server.address();\n\n // istanbul ignore next\n if (!address) throw new Error('Server is not listening');\n\n // istanbul ignore next\n if (typeof address === 'string') throw new Error('Server is listening on a pipe');\n\n return address.port;\n}\n"]}
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@prairielearn/express-test-utils",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "type": "module",
5
- "main": "dist/index.js",
6
5
  "repository": {
7
6
  "type": "git",
8
7
  "url": "https://github.com/PrairieLearn/PrairieLearn.git",
9
8
  "directory": "packages/express-test-utils"
10
9
  },
10
+ "main": "dist/index.js",
11
11
  "scripts": {
12
12
  "build": "tsc",
13
13
  "dev": "tsc --watch --preserveWatchOutput"
14
14
  },
15
15
  "dependencies": {
16
- "@types/express": "^4.17.21"
16
+ "@types/express": "^4.17.23"
17
17
  }
18
18
  }
package/src/index.ts CHANGED
@@ -1,5 +1,6 @@
1
- import * as express from 'express';
2
- import { Server } from 'node:http';
1
+ import { type Server } from 'node:http';
2
+
3
+ import { type Express } from 'express';
3
4
 
4
5
  export interface WithServerContext {
5
6
  server: Server;
@@ -7,10 +8,7 @@ export interface WithServerContext {
7
8
  url: string;
8
9
  }
9
10
 
10
- export async function withServer(
11
- app: express.Express,
12
- fn: (ctx: WithServerContext) => Promise<void>,
13
- ) {
11
+ export async function withServer(app: Express, fn: (ctx: WithServerContext) => Promise<void>) {
14
12
  const server = app.listen();
15
13
 
16
14
  await new Promise<void>((resolve, reject) => {