@stamhoofd/backend-renderer 2.153.0 → 2.160.0

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.
Files changed (61) hide show
  1. package/LICENSE.md +7 -7
  2. package/README.md +11 -1
  3. package/dist/boot.js +83 -0
  4. package/dist/boot.js.map +1 -0
  5. package/dist/classes/TrustedIPWhitelist.js +204 -0
  6. package/dist/classes/TrustedIPWhitelist.js.map +1 -0
  7. package/dist/endpoints/HealthEndpoint.js +76 -0
  8. package/dist/endpoints/HealthEndpoint.js.map +1 -0
  9. package/dist/endpoints/HtmlToPdfEndpoint.js +220 -0
  10. package/dist/endpoints/HtmlToPdfEndpoint.js.map +1 -0
  11. package/dist/endpoints/PdfCacheEndpoint.js +66 -0
  12. package/dist/endpoints/PdfCacheEndpoint.js.map +1 -0
  13. package/dist/endpoints/PrerenderEndpoint.js +276 -0
  14. package/dist/endpoints/PrerenderEndpoint.js.map +1 -0
  15. package/dist/helpers/FileCache.js +51 -0
  16. package/dist/helpers/FileCache.js.map +1 -0
  17. package/dist/helpers/TTLFileCache.js +83 -0
  18. package/dist/helpers/TTLFileCache.js.map +1 -0
  19. package/dist/index.js +7 -6
  20. package/dist/index.js.map +1 -0
  21. package/dist-types/boot.d.ts +3 -0
  22. package/dist-types/boot.d.ts.map +1 -0
  23. package/dist-types/classes/TrustedIPWhitelist.d.ts +72 -0
  24. package/dist-types/classes/TrustedIPWhitelist.d.ts.map +1 -0
  25. package/dist-types/endpoints/HealthEndpoint.d.ts +24 -0
  26. package/dist-types/endpoints/HealthEndpoint.d.ts.map +1 -0
  27. package/dist-types/endpoints/HtmlToPdfEndpoint.d.ts +37 -0
  28. package/dist-types/endpoints/HtmlToPdfEndpoint.d.ts.map +1 -0
  29. package/dist-types/endpoints/PdfCacheEndpoint.d.ts +28 -0
  30. package/dist-types/endpoints/PdfCacheEndpoint.d.ts.map +1 -0
  31. package/dist-types/endpoints/PrerenderEndpoint.d.ts +56 -0
  32. package/dist-types/endpoints/PrerenderEndpoint.d.ts.map +1 -0
  33. package/dist-types/helpers/FileCache.d.ts +11 -0
  34. package/dist-types/helpers/FileCache.d.ts.map +1 -0
  35. package/dist-types/helpers/TTLFileCache.d.ts +10 -0
  36. package/dist-types/helpers/TTLFileCache.d.ts.map +1 -0
  37. package/dist-types/index.d.ts +2 -0
  38. package/dist-types/index.d.ts.map +1 -0
  39. package/package.json +40 -26
  40. package/src/boot.ts +6 -8
  41. package/src/classes/TrustedIPWhitelist.ts +1 -1
  42. package/src/endpoints/HealthEndpoint.test.ts +1 -1
  43. package/src/endpoints/HealthEndpoint.ts +4 -4
  44. package/src/endpoints/HtmlToPdfEndpoint.test.ts +94 -0
  45. package/src/endpoints/HtmlToPdfEndpoint.ts +33 -15
  46. package/src/endpoints/PdfCacheEndpoint.test.ts +46 -0
  47. package/src/endpoints/PdfCacheEndpoint.ts +23 -5
  48. package/src/endpoints/PrerenderEndpoint.test.ts +19 -1
  49. package/src/endpoints/PrerenderEndpoint.ts +10 -9
  50. package/src/helpers/FileCache.test.ts +27 -0
  51. package/src/helpers/FileCache.ts +5 -24
  52. package/src/helpers/TTLFileCache.ts +7 -7
  53. package/src/index.ts +7 -6
  54. package/tsconfig.build.json +4 -9
  55. package/tsconfig.json +1 -1
  56. package/tsconfig.test.json +2 -4
  57. package/tsconfig.types.json +7 -0
  58. package/.gitignore +0 -223
  59. package/tests/vitest.global.setup.ts +0 -20
  60. package/tests/vitest.setup.ts +0 -31
  61. package/vitest.config.js +0 -20
@@ -0,0 +1,46 @@
1
+ import { Request, TestServer } from '@stamhoofd/node-endpoints';
2
+ import { signInternal } from '@stamhoofd/backend-env';
3
+ import { FileCache } from '../helpers/FileCache.js';
4
+ import { PdfCacheEndpoint } from './PdfCacheEndpoint.js';
5
+
6
+ /** Exercises request decoding and signature verification with cache I/O stubbed. */
7
+ describe('PDF cache authorization', () => {
8
+ const endpoint = new PdfCacheEndpoint();
9
+ const server = new TestServer();
10
+ const cacheId = 'document-123';
11
+ const timestamp = 2000;
12
+
13
+ beforeEach(() => {
14
+ vi.spyOn(FileCache, 'read').mockResolvedValue(Buffer.from('PDF'));
15
+ });
16
+
17
+ afterEach(() => vi.restoreAllMocks());
18
+
19
+ /**
20
+ * A grant authorizes only its signed cache ID and exact version while unexpired.
21
+ * Mutating request fields after signing must fail without accessing cached bytes;
22
+ * missing fields must also be rejected by request decoding.
23
+ */
24
+ test.each(['missing', 'expired', 'changed version', 'changed ID', 'invalid signature'])('rejects %s authorization before reading the cache', async (mode) => {
25
+ const expires = Date.now() + (mode === 'expired' ? -1000 : 60000);
26
+ const signature = signInternal('pdf-cache', cacheId, String(timestamp), String(expires));
27
+ const query = {
28
+ cacheId: mode === 'changed ID' ? 'invoice-123' : cacheId,
29
+ timestamp: mode === 'changed version' ? timestamp + 1 : timestamp,
30
+ ...(mode === 'missing' ? {} : { expires, signature: mode === 'invalid signature' ? 'invalid' : signature }),
31
+ };
32
+ await expect(server.test(endpoint, Request.get({ path: '/pdf-cache', query }))).rejects.toThrow();
33
+ expect(FileCache.read).not.toHaveBeenCalled();
34
+ });
35
+
36
+ /** Valid grants work for both cache namespaces and pass the signed version to storage unchanged. */
37
+ test.each(['document-123', 'invoice-123'])('returns an authorized exact version of %s', async (cacheId) => {
38
+ const expires = Date.now() + 60000;
39
+ const signature = signInternal('pdf-cache', cacheId, String(timestamp), String(expires));
40
+ const response = await server.test(endpoint, Request.get({
41
+ path: '/pdf-cache', query: { cacheId, timestamp, expires, signature },
42
+ }));
43
+ expect(response.body).toEqual(Buffer.from('PDF'));
44
+ expect(FileCache.read).toHaveBeenCalledWith(cacheId, new Date(timestamp));
45
+ });
46
+ });
@@ -1,8 +1,9 @@
1
- import type { Decoder} from '@simonbackx/simple-encoding';
2
- import { AutoEncoder, DateDecoder, field, StringDecoder } from '@simonbackx/simple-encoding';
3
- import type { DecodedRequest, Request} from '@simonbackx/simple-endpoints';
4
- import { Endpoint, Response } from '@simonbackx/simple-endpoints';
5
- import { SimpleError } from '@simonbackx/simple-errors';
1
+ import type { Decoder } from '@stamhoofd/common-encoding';
2
+ import { AutoEncoder, DateDecoder, field, StringDecoder } from '@stamhoofd/common-encoding';
3
+ import type { DecodedRequest, Request } from '@stamhoofd/node-endpoints';
4
+ import { Endpoint, Response } from '@stamhoofd/node-endpoints';
5
+ import { SimpleError } from '@stamhoofd/common-errors';
6
+ import { verifyInternalSignature } from '@stamhoofd/backend-env';
6
7
 
7
8
  import { FileCache } from '../helpers/FileCache.js';
8
9
 
@@ -13,6 +14,12 @@ class Query extends AutoEncoder {
13
14
 
14
15
  @field({ decoder: DateDecoder })
15
16
  timestamp: Date;
17
+
18
+ @field({ decoder: DateDecoder })
19
+ expires: Date;
20
+
21
+ @field({ decoder: StringDecoder })
22
+ signature: string;
16
23
  }
17
24
  type Body = undefined;
18
25
  type ResponseBody = Buffer;
@@ -37,7 +44,17 @@ export class PdfCacheEndpoint extends Endpoint<Params, Query, Body, ResponseBody
37
44
  return [false];
38
45
  }
39
46
 
47
+ /**
48
+ * Returns cached PDF bytes only for the ID and exact version in a valid cache-read
49
+ * grant. Expiry must be in the next minute; verification precedes all cache I/O.
50
+ * A valid grant with no readable version produces cache_not_found.
51
+ */
40
52
  async handle(request: DecodedRequest<Params, Query, Body>) {
53
+ const { cacheId, timestamp, expires, signature } = request.query;
54
+ if (expires.getTime() <= Date.now() || expires.getTime() > Date.now() + 60000
55
+ || !verifyInternalSignature(signature, 'pdf-cache', cacheId, String(timestamp.getTime()), String(expires.getTime()))) {
56
+ throw new SimpleError({ code: 'invalid_signature', message: 'Invalid signature', statusCode: 403 });
57
+ }
41
58
  const pdf = await FileCache.read(request.query.cacheId, request.query.timestamp);
42
59
  if (!pdf) {
43
60
  throw new SimpleError({
@@ -47,6 +64,7 @@ export class PdfCacheEndpoint extends Endpoint<Params, Query, Body, ResponseBody
47
64
  });
48
65
  }
49
66
  const response = new Response(pdf);
67
+ response.headers['Cache-Control'] = 'no-store';
50
68
  response.headers['Content-Type'] = 'application/pdf';
51
69
  response.headers['Content-Length'] = pdf.byteLength.toString();
52
70
  return response;
@@ -1,10 +1,28 @@
1
- import { Request, TestServer } from '@simonbackx/simple-endpoints';
1
+ import { Request, TestServer } from '@stamhoofd/node-endpoints';
2
2
  import { PrerenderEndpoint } from './PrerenderEndpoint.js';
3
3
  import nock from 'nock';
4
4
  import { STExpect, TestUtils } from '@stamhoofd/test-utils';
5
5
  import fs from 'fs/promises';
6
6
  import { TrustedIPWhitelist } from '../classes/TrustedIPWhitelist.js';
7
7
 
8
+ describe('cleanHeaders dictionary isolation', () => {
9
+ test('preserves special response header names without mutating the result prototype', () => {
10
+ const input = JSON.parse('{"__proto__":"first","constructor":"second","prototype":"third"}');
11
+ const output = PrerenderEndpoint.cleanHeaders(input);
12
+ expect(Object.getPrototypeOf(output)).toBe(Object.prototype);
13
+ expect(Object.getOwnPropertyDescriptor(output, '__proto__')?.value).toBe('first');
14
+ expect(output).toEqual(input);
15
+ });
16
+
17
+ test('rejects structured values instead of treating them as header prototype state', () => {
18
+ const input = JSON.parse('{"__proto__":{"location":"https://untrusted.example"}}');
19
+ const output = PrerenderEndpoint.cleanHeaders(input);
20
+ expect(Object.getPrototypeOf(output)).toBe(Object.prototype);
21
+ expect(output).toEqual({});
22
+ expect(output.location).toBeUndefined();
23
+ });
24
+ });
25
+
8
26
  async function fileExists(path: string): Promise<boolean> {
9
27
  try {
10
28
  await fs.access(path, fs.constants.F_OK);
@@ -1,9 +1,9 @@
1
- import type { DecodedRequest, Request } from '@simonbackx/simple-endpoints';
2
- import { Endpoint, Response } from '@simonbackx/simple-endpoints';
3
- import { SimpleError } from '@simonbackx/simple-errors';
1
+ import type { DecodedRequest, Request } from '@stamhoofd/node-endpoints';
2
+ import { Endpoint, Response } from '@stamhoofd/node-endpoints';
3
+ import { SimpleError } from '@stamhoofd/common-errors';
4
4
 
5
- import type { Decoder } from '@simonbackx/simple-encoding';
6
- import { AutoEncoder, field, URLDecoder } from '@simonbackx/simple-encoding';
5
+ import type { Decoder } from '@stamhoofd/common-encoding';
6
+ import { AutoEncoder, field, URLDecoder } from '@stamhoofd/common-encoding';
7
7
  import { TrustedIPWhitelist } from '../classes/TrustedIPWhitelist.js';
8
8
  import { TTLFileCache } from '../helpers/TTLFileCache.js';
9
9
  import { HtmlToPdfEndpoint } from './HtmlToPdfEndpoint.js';
@@ -155,11 +155,12 @@ export class PrerenderEndpoint extends Endpoint<Params, Query, Body, ResponseBod
155
155
  return parsed.href;
156
156
  }
157
157
 
158
+ /** Normalizes literal header keys in a Map, returning the object required by the HTTP boundary. */
158
159
  static cleanHeaders(headers: Record<string, string | undefined>): Record<string, string> {
159
- const cleanedHeaders: Record<string, string> = {};
160
+ const cleanedHeaders = new Map<string, string>();
160
161
  for (const key of Object.keys(headers)) {
161
162
  const rawValue = headers[key];
162
- if (!rawValue) {
163
+ if (typeof rawValue !== 'string' || !rawValue) {
163
164
  continue;
164
165
  }
165
166
  const l = key.toLowerCase();
@@ -169,9 +170,9 @@ export class PrerenderEndpoint extends Endpoint<Params, Query, Body, ResponseBod
169
170
  if (/[\r\n]/.test(rawValue)) {
170
171
  continue;
171
172
  }
172
- cleanedHeaders[l] = rawValue;
173
+ cleanedHeaders.set(l, rawValue);
173
174
  }
174
- return cleanedHeaders;
175
+ return Object.fromEntries(cleanedHeaders);
175
176
  }
176
177
 
177
178
  static async getUrlHtml(url: string, options: { retryCount: number; startDate: Date }): Promise<Data | null> {
@@ -0,0 +1,27 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ import { promises as fs } from 'node:fs';
3
+ import { FileCache } from './FileCache.js';
4
+
5
+ /** Exercises on-disk version selection without sharing cache entries with other tests. */
6
+ describe('FileCache exact versions', () => {
7
+ const cacheId = `document-${randomUUID()}`;
8
+
9
+ afterEach(async () => {
10
+ await fs.rm(`${STAMHOOFD.CACHE_PATH}/${cacheId}`, { recursive: true, force: true });
11
+ });
12
+
13
+ /** An existing later timestamp is a cache miss, not a substitute for the requested document. */
14
+ test('does not return a newer document for an older version', async () => {
15
+ await FileCache.write(cacheId, new Date(2000), Buffer.from('newer document'));
16
+
17
+ expect(await FileCache.read(cacheId, new Date(1000))).toBeNull();
18
+ });
19
+
20
+ /** Positive control: matching timestamps return the stored PDF bytes unchanged. */
21
+ test('returns the exact requested version', async () => {
22
+ const pdf = Buffer.from('requested document');
23
+ await FileCache.write(cacheId, new Date(2000), pdf);
24
+
25
+ expect(await FileCache.read(cacheId, new Date(2000))).toEqual(pdf);
26
+ });
27
+ });
@@ -1,10 +1,10 @@
1
- import { SimpleError } from '@simonbackx/simple-errors';
1
+ import { SimpleError } from '@stamhoofd/common-errors';
2
2
  import { promises as fs } from 'fs';
3
3
 
4
4
  /**
5
- * This cache does not use a TTL.
5
+ * This cache does not use a TTL.
6
6
  * Instead it uses the updatedAt timestamp of a resource when caching. So we keep the cache forever unless the resource itself has changed.
7
- * The cache requester passes the updatedAt timestamp, so this works flawlessly.
7
+ * Reads only return the exact requested updatedAt timestamp, never a later version.
8
8
  */
9
9
  export class FileCache {
10
10
  static async write(cacheId: string, timestamp: Date, data: Uint8Array | Buffer) {
@@ -32,6 +32,7 @@ export class FileCache {
32
32
  await fs.writeFile(path, data);
33
33
  }
34
34
 
35
+ /** Returns bytes for this exact resource version, or null when its file cannot be read. */
35
36
  static async read(cacheId: string, timestamp: Date): Promise<Buffer | null> {
36
37
  if (cacheId.includes('/')) {
37
38
  throw new SimpleError({
@@ -46,27 +47,7 @@ export class FileCache {
46
47
  try {
47
48
  const data = await fs.readFile(path);
48
49
  return data;
49
- }
50
- catch {
51
- // ignore
52
- }
53
-
54
- try {
55
- const files = await fs.readdir(folder);
56
- for (const file of files) {
57
- const fileTimestamp = parseInt(file.substring(0, file.length - 4));
58
- if (fileTimestamp >= timestamp.getTime()) {
59
- try {
60
- const data = await fs.readFile(folder + '/' + file);
61
- return data;
62
- }
63
- catch {
64
- // ignore
65
- }
66
- }
67
- }
68
- }
69
- catch {
50
+ } catch {
70
51
  // ignore
71
52
  }
72
53
 
@@ -7,15 +7,15 @@ export class TTLFileCache {
7
7
 
8
8
  constructor(name: string, ttl: number) {
9
9
  if (!STAMHOOFD.CACHE_PATH) {
10
- throw new Error('Missing STAMHOOFD.CACHE_PATH')
10
+ throw new Error('Missing STAMHOOFD.CACHE_PATH');
11
11
  }
12
- this.cachePath = STAMHOOFD.CACHE_PATH + '/' + Formatter.slug(name)
12
+ this.cachePath = STAMHOOFD.CACHE_PATH + '/' + Formatter.slug(name);
13
13
 
14
14
  // Clear on boot
15
- this.clear().catch(console.error)
15
+ this.clear().catch(console.error);
16
16
  }
17
17
 
18
- keyToFilePath(key: string): string {
18
+ keyToFilePath(key: string): string {
19
19
  // Percent-encode every character that isn't safe in a filename.
20
20
  // Using encoding rather than replacement ensures the mapping is
21
21
  // injective: no two distinct keys ever produce the same filename.
@@ -28,7 +28,6 @@ export class TTLFileCache {
28
28
  return path.join(this.cachePath, safeKey);
29
29
  }
30
30
 
31
-
32
31
  async cacheFile(key: string, contents: string): Promise<void> {
33
32
  await fs.mkdir(this.cachePath, { recursive: true });
34
33
  await fs.writeFile(this.keyToFilePath(key), contents, 'utf-8');
@@ -54,7 +53,7 @@ export class TTLFileCache {
54
53
 
55
54
  async clear() {
56
55
  try {
57
- await fs.rm(this.cachePath, {recursive: true})
56
+ await fs.rm(this.cachePath, { recursive: true });
58
57
  } catch (e) {
59
58
  // ignore
60
59
  }
@@ -80,12 +79,13 @@ export class TTLFileCache {
80
79
  try {
81
80
  const stat = await fs.stat(filePath);
82
81
  if (stat.isFile() && stat.mtimeMs < cutoff) {
82
+ // eslint-disable-next-line node-security/no-toctou-vulnerability -- The stat only selects expired cache entries, not access permissions; unlink does not follow symlinks and concurrent deletion is caught below.
83
83
  await fs.unlink(filePath);
84
84
  }
85
85
  } catch {
86
86
  // File may have been deleted concurrently — ignore
87
87
  }
88
- })
88
+ }),
89
89
  );
90
90
  }
91
91
  }
package/src/index.ts CHANGED
@@ -1,12 +1,13 @@
1
1
  import backendEnv from '@stamhoofd/backend-env';
2
+ import { BackendApp } from '@stamhoofd/types/BackendApp';
3
+ import { runApplication } from '@stamhoofd/node-observability';
2
4
 
3
5
  process.title = 'stamhoofd-renderer';
4
- backendEnv.load({ service: 'renderer' }).catch((error) => {
5
- console.error('Failed to load environment:', error);
6
- process.exit(1);
7
- }).then(async () => {
8
- await import('./boot.js');
6
+ runApplication('renderer', async (lifecycle) => {
7
+ await backendEnv.load({ service: BackendApp.Renderer });
8
+ const { boot } = await import('./boot.js');
9
+ await boot(lifecycle);
9
10
  }).catch((error) => {
10
- console.error('Failed to start the API:', error);
11
+ console.error('Failed to start the renderer:', error);
11
12
  process.exit(1);
12
13
  });
@@ -1,15 +1,10 @@
1
1
  {
2
- "extends": "../../../tsconfig.base.json",
2
+ "extends": ["../../../tsconfig.base.json", "../../../tsconfig.runtime.json"],
3
3
  "compilerOptions": {
4
+ "tsBuildInfoFile": ".cache/build.tsbuildinfo",
4
5
  "rootDir": "./src",
5
6
  "outDir": "dist"
6
7
  },
7
- "include": [
8
- "./src",
9
- "./stamhoofd.d.ts"
10
- ],
11
- "exclude": [
12
- "./src/**/*.spec.ts",
13
- "./src/**/*.test.ts"
14
- ]
8
+ "include": ["./src", "./stamhoofd.d.ts"],
9
+ "exclude": ["./src/**/*.spec.ts", "./src/**/*.test.ts"]
15
10
  }
package/tsconfig.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "files": [],
4
4
  "references": [
5
5
  {
6
- "path": "./tsconfig.build.json"
6
+ "path": "./tsconfig.types.json"
7
7
  },
8
8
  {
9
9
  "path": "./tsconfig.test.json"
@@ -5,13 +5,11 @@
5
5
  "outDir": "dist",
6
6
  "noEmit": true
7
7
  },
8
- "references": [
9
- { "path": "./tsconfig.build.json" }
10
- ],
8
+ "references": [{ "path": "./tsconfig.types.json" }],
11
9
  "include": [
12
10
  "./stamhoofd.d.ts",
13
11
  "../../../jest-extended.d.ts",
14
- "./src/**/*.spec.ts",
12
+ "./src/**/*.spec.ts",
15
13
  "./src/**/*.test.ts",
16
14
  "./tests"
17
15
  ]
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": ["./tsconfig.build.json", "../../../tsconfig.types.json"],
3
+ "compilerOptions": {
4
+ "outDir": "dist-types",
5
+ "tsBuildInfoFile": ".cache/types.tsbuildinfo"
6
+ }
7
+ }
package/.gitignore DELETED
@@ -1,223 +0,0 @@
1
- /devops/
2
- node_modules/
3
- .node_modules/
4
- built/*
5
- tests/cases/rwc/*
6
- tests/cases/test262/*
7
- tests/cases/perf/*
8
- !tests/cases/webharness/compilerToString.js
9
- test-args.txt
10
- ~*.docx
11
- \#*\#
12
- .\#*
13
- tests/baselines/local/*
14
- tests/baselines/local.old/*
15
- tests/services/baselines/local/*
16
- tests/baselines/prototyping/local/*
17
- tests/baselines/rwc/*
18
- tests/baselines/test262/*
19
- tests/baselines/reference/projectOutput/*
20
- tests/baselines/local/projectOutput/*
21
- tests/baselines/reference/testresults.tap
22
- tests/services/baselines/prototyping/local/*
23
- tests/services/browser/typescriptServices.js
24
- src/harness/*.js
25
- src/compiler/diagnosticInformationMap.generated.ts
26
- src/compiler/diagnosticMessages.generated.json
27
- src/parser/diagnosticInformationMap.generated.ts
28
- src/parser/diagnosticMessages.generated.json
29
- rwc-report.html
30
- *.swp
31
- build.json
32
- *.actual
33
- tests/webTestServer.js
34
- tests/webTestServer.js.map
35
- tests/webhost/*.d.ts
36
- tests/webhost/webtsc.js
37
- tests/cases/**/*.js
38
- !tests/cases/docker/*.js/
39
- tests/cases/**/*.js.map
40
- *.config
41
- scripts/eslint/built/
42
- scripts/debug.bat
43
- scripts/run.bat
44
- scripts/word2md.js
45
- scripts/buildProtocol.js
46
- scripts/ior.js
47
- scripts/authors.js
48
- scripts/configurePrerelease.js
49
- scripts/configureLanguageServiceBuild.js
50
- scripts/open-user-pr.js
51
- scripts/open-cherry-pick-pr.js
52
- scripts/processDiagnosticMessages.d.ts
53
- scripts/processDiagnosticMessages.js
54
- scripts/produceLKG.js
55
- scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.js
56
- scripts/generateLocalizedDiagnosticMessages.js
57
- scripts/request-pr-review.js
58
- scripts/*.js.map
59
- scripts/typings/
60
- coverage/
61
- internal/
62
- **/.DS_Store
63
- .settings
64
- !tests/cases/projects/projectOption/**/node_modules
65
- !tests/cases/projects/NodeModulesSearch/**/*
66
- !tests/baselines/reference/project/nodeModules*/**/*
67
- .idea
68
- yarn-error.log
69
- .parallelperf.*
70
- tests/cases/user/*/package-lock.json
71
- tests/cases/user/*/node_modules/
72
- tests/cases/user/*/**/*.js
73
- tests/cases/user/*/**/*.js.map
74
- tests/cases/user/*/**/*.d.ts
75
- !tests/cases/user/zone.js/
76
- !tests/cases/user/bignumber.js/
77
- !tests/cases/user/discord.js/
78
- tests/baselines/reference/dt
79
- .failed-tests
80
- TEST-results.xml
81
- package-lock.json
82
- tests/cases/user/TypeScript-React-Starter/TypeScript-React-Starter
83
- tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter
84
- tests/cases/user/TypeScript-React-Native-Starter/TypeScript-React-Native-Starter
85
- tests/cases/user/TypeScript-Vue-Starter/TypeScript-Vue-Starter
86
- tests/cases/user/TypeScript-WeChat-Starter/TypeScript-WeChat-Starter
87
- tests/cases/user/create-react-app/create-react-app
88
- tests/cases/user/fp-ts/fp-ts
89
- tests/cases/user/webpack/webpack
90
- tests/cases/user/puppeteer/puppeteer
91
- tests/cases/user/axios-src/axios-src
92
- tests/cases/user/prettier/prettier
93
- .eslintcache
94
-
95
- # Logs
96
- logs
97
- *.log
98
- npm-debug.log*
99
- yarn-debug.log*
100
- yarn-error.log*
101
- lerna-debug.log*
102
-
103
- # Diagnostic reports (https://nodejs.org/api/report.html)
104
- report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
105
-
106
- # Runtime data
107
- pids
108
- *.pid
109
- *.seed
110
- *.pid.lock
111
-
112
- # Directory for instrumented libs generated by jscoverage/JSCover
113
- lib-cov
114
-
115
- # Coverage directory used by tools like istanbul
116
- coverage
117
- *.lcov
118
-
119
- # nyc test coverage
120
- .nyc_output
121
-
122
- # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
123
- .grunt
124
-
125
- # Bower dependency directory (https://bower.io/)
126
- bower_components
127
-
128
- # node-waf configuration
129
- .lock-wscript
130
-
131
- # Compiled binary addons (https://nodejs.org/api/addons.html)
132
- build/Release
133
-
134
- # Dependency directories
135
- node_modules/
136
- jspm_packages/
137
-
138
- # Snowpack dependency directory (https://snowpack.dev/)
139
- web_modules/
140
-
141
- # TypeScript cache
142
- *.tsbuildinfo
143
-
144
- # Optional npm cache directory
145
- .npm
146
-
147
- # Optional eslint cache
148
- .eslintcache
149
-
150
- # Microbundle cache
151
- .rpt2_cache/
152
- .rts2_cache_cjs/
153
- .rts2_cache_es/
154
- .rts2_cache_umd/
155
-
156
- # Optional REPL history
157
- .node_repl_history
158
-
159
- # Output of 'npm pack'
160
- *.tgz
161
-
162
- # Yarn Integrity file
163
- .yarn-integrity
164
-
165
- # dotenv environment variables file
166
- .env
167
- .env.test
168
-
169
- # parcel-bundler cache (https://parceljs.org/)
170
- .cache
171
- cache
172
- .parcel-cache
173
-
174
- # Next.js build output
175
- .next
176
-
177
- # Nuxt.js build / generate output
178
- .nuxt
179
- dist
180
-
181
- # Gatsby files
182
- .cache/
183
- # Comment in the public line in if your project uses Gatsby and not Next.js
184
- # https://nextjs.org/blog/next-9-1#public-directory-support
185
- # public
186
-
187
- # vuepress build output
188
- .vuepress/dist
189
-
190
- # Serverless directories
191
- .serverless/
192
-
193
- # FuseBox cache
194
- .fusebox/
195
-
196
- # DynamoDB Local files
197
- .dynamodb/
198
-
199
- # TernJS port file
200
- .tern-port
201
-
202
- # Stores VSCode versions used for testing VSCode extensions
203
- .vscode-test
204
-
205
- # yarn v2
206
-
207
- .yarn/cache
208
- .yarn/unplugged
209
- .yarn/build-state.yml
210
- .pnp.*
211
-
212
- .yalc
213
- yalc.lock
214
-
215
- .yarn
216
-
217
- # Yarnrc should be removed from git, because it breaks yarn if the version is not installed yet
218
- .yarnrc
219
-
220
- .env.json
221
- .env.*.json
222
- !.env.template.json
223
- /.test-cache
@@ -1,20 +0,0 @@
1
- // first import nock
2
- import nock from 'nock';
3
-
4
- // prevent nock import from being removed on save
5
- console.log('Imported nock: ', !!nock);
6
-
7
- import { TestUtils } from '@stamhoofd/test-utils';
8
-
9
-
10
- // Set timezone!
11
- process.env.TZ = 'UTC';
12
-
13
- // Quick check
14
- if (new Date().getTimezoneOffset() !== 0) {
15
- throw new Error('Process should always run in UTC timezone');
16
- }
17
-
18
- export async function setup() {
19
- TestUtils.globalSetup();
20
- };
@@ -1,31 +0,0 @@
1
- // first import nock
2
-
3
- import { Column } from '@simonbackx/simple-database';
4
- import { Request } from '@simonbackx/simple-endpoints';
5
- import { Version } from '@stamhoofd/structures';
6
- import { TestUtils } from '@stamhoofd/test-utils';
7
-
8
- Error.stackTraceLimit = 100;
9
-
10
- // Set version of saved structures
11
- Column.setJSONVersion(Version);
12
-
13
- // Automatically set endpoint default version to latest one (only in tests!)
14
- Request.defaultVersion = Version;
15
-
16
- // Set timezone!
17
- process.env.TZ = 'UTC';
18
-
19
- // Quick check
20
- if (new Date().getTimezoneOffset() !== 0) {
21
- throw new Error('Process should always run in UTC timezone');
22
- }
23
-
24
- console.log = () => {};
25
-
26
- beforeAll(async () => {
27
- // Override default $t handlers
28
- TestUtils.loadEnvironment();
29
- });
30
- TestUtils.setPermanentEnvironment('CACHE_PATH', import.meta.dirname + '/../.test-cache')
31
- TestUtils.setup();