@sqrzro/addons 4.0.0-alpha.14 → 4.0.0-alpha.15
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/dist/src/cli/get-config.d.ts +3 -0
- package/dist/src/cli/get-config.js +21 -0
- package/dist/src/cli/index.d.ts +2 -0
- package/dist/src/cli/index.js +2 -0
- package/dist/src/cli/utility/interfaces.d.ts +3 -0
- package/dist/src/cli/utility/interfaces.js +1 -0
- package/dist/src/extend-proxy.d.ts +4 -0
- package/dist/src/extend-proxy.js +21 -0
- package/dist/src/extend-repository.d.ts +7 -0
- package/dist/src/extend-repository.js +4 -0
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.js +3 -0
- package/dist/src/interfaces.d.ts +4 -0
- package/dist/src/interfaces.js +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
const NAME = 'sqrzro';
|
|
4
|
+
function getConfigPath() {
|
|
5
|
+
const files = fs.readdirSync(process.cwd());
|
|
6
|
+
for (const file of files) {
|
|
7
|
+
if (file.match(new RegExp(`^${NAME}\\.config\\.(js|ts|cjs|mjs)$`))) {
|
|
8
|
+
return path.resolve(process.cwd(), file);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
async function getConfig() {
|
|
14
|
+
const configPath = getConfigPath();
|
|
15
|
+
if (!configPath) {
|
|
16
|
+
return {};
|
|
17
|
+
}
|
|
18
|
+
const config = await import(configPath);
|
|
19
|
+
return 'default' in config ? config.default : {};
|
|
20
|
+
}
|
|
21
|
+
export default getConfig;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { NextRequest } from 'next/server';
|
|
2
|
+
import type { AddonProxyResponse } from './interfaces';
|
|
3
|
+
declare function extendProxy(request: NextRequest, ...fns: Array<(request: NextRequest, response: AddonProxyResponse) => Promise<AddonProxyResponse>>): Promise<Response>;
|
|
4
|
+
export default extendProxy;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { NextResponse } from 'next/server';
|
|
2
|
+
async function extendProxy(request, ...fns) {
|
|
3
|
+
const { pathname } = request.nextUrl;
|
|
4
|
+
let response = { data: {} };
|
|
5
|
+
for (const fn of fns) {
|
|
6
|
+
response = await fn(request, response);
|
|
7
|
+
if (response.redirect) {
|
|
8
|
+
const { redirect } = response;
|
|
9
|
+
if (typeof redirect === 'number') {
|
|
10
|
+
return new Response(null, { status: redirect });
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
return response.redirect === pathname
|
|
14
|
+
? NextResponse.next()
|
|
15
|
+
: NextResponse.redirect(new URL(redirect, request.url));
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return NextResponse.next();
|
|
20
|
+
}
|
|
21
|
+
export default extendProxy;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
declare function extendRepository<T, A>(repository: T, fn1: (repository: T) => A): A;
|
|
2
|
+
declare function extendRepository<T, A, B>(repository: T, fn1: (repository: T) => A, fn2: (repository: A) => B): B;
|
|
3
|
+
declare function extendRepository<T, A, B, C>(repository: T, fn1: (repository: T) => A, fn2: (repository: A) => B, fn3: (repository: B) => C): C;
|
|
4
|
+
declare function extendRepository<T, A, B, C, D>(repository: T, fn1: (repository: T) => A, fn2: (repository: A) => B, fn3: (repository: B) => C, fn4: (repository: C) => D): D;
|
|
5
|
+
declare function extendRepository<T, A, B, C, D, E>(repository: T, fn1: (repository: T) => A, fn2: (repository: A) => B, fn3: (repository: B) => C, fn4: (repository: C) => D, fn5: (repository: D) => E): E;
|
|
6
|
+
declare function extendRepository<T, A, B, C, D, E, F>(repository: T, fn1: (repository: T) => A, fn2: (repository: A) => B, fn3: (repository: B) => C, fn4: (repository: C) => D, fn5: (repository: D) => E, fn6: (repository: E) => F): F;
|
|
7
|
+
export default extendRepository;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sqrzro/addons",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.0.0-alpha.
|
|
4
|
+
"version": "4.0.0-alpha.15",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"license": "ISC",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"dist/**/*"
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"next": "^16.
|
|
26
|
+
"next": "^16.4.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"typescript": "^5.9.3"
|