@nubase/create 0.1.15 → 0.1.16
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/index.js +3 -0
- package/package.json +1 -1
- package/templates/backend/package.json +1 -1
- package/templates/backend/src/api/routes/index.ts +1 -0
- package/templates/backend/src/api/routes/user.ts +37 -0
- package/templates/backend/src/preflight.ts +18 -0
- package/templates/frontend/src/config.tsx +2 -0
- package/templates/frontend/src/resources/user.ts +10 -0
- package/templates/root/package.json +6 -6
- package/templates/root/scripts/check-docker.sh +13 -0
- package/templates/schema/src/api-endpoints.ts +4 -0
- package/templates/schema/src/endpoints/user/index.ts +1 -0
- package/templates/schema/src/endpoints/user/lookup-users.ts +3 -0
package/dist/index.js
CHANGED
|
@@ -45,6 +45,9 @@ function copyTemplateDir(src, dest, options) {
|
|
|
45
45
|
const content = fs.readFileSync(srcPath, "utf-8");
|
|
46
46
|
const processedContent = replaceInContent(content, options);
|
|
47
47
|
fs.writeFileSync(destPath, processedContent, "utf-8");
|
|
48
|
+
if (destName.endsWith(".sh")) {
|
|
49
|
+
fs.chmodSync(destPath, 493);
|
|
50
|
+
}
|
|
48
51
|
}
|
|
49
52
|
}
|
|
50
53
|
}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"version": "0.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"dev": "NODE_ENV=development tsx watch src/index.ts",
|
|
6
|
+
"dev": "NODE_ENV=development tsx src/preflight.ts && NODE_ENV=development tsx watch src/index.ts",
|
|
7
7
|
"dev:test": "PORT=__TEST_BACKEND_PORT__ DB_PORT=__TEST_PORT__ NODE_ENV=test tsx watch src/index.ts",
|
|
8
8
|
"build": "tsc",
|
|
9
9
|
"start": "node dist/index.js",
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { createHttpHandler } from "@nubase/backend";
|
|
2
|
+
import { ilike } from "drizzle-orm";
|
|
3
|
+
import { apiEndpoints } from "schema";
|
|
4
|
+
import { getDb } from "../../db/helpers/drizzle";
|
|
5
|
+
import { users } from "../../db/schema";
|
|
6
|
+
|
|
7
|
+
export const userHandlers = {
|
|
8
|
+
lookupUsers: createHttpHandler({
|
|
9
|
+
endpoint: apiEndpoints.lookupUsers,
|
|
10
|
+
handler: async ({ params }) => {
|
|
11
|
+
const db = getDb();
|
|
12
|
+
|
|
13
|
+
// Build query with optional search filter
|
|
14
|
+
let query = db
|
|
15
|
+
.select({
|
|
16
|
+
id: users.id,
|
|
17
|
+
displayName: users.displayName,
|
|
18
|
+
email: users.email,
|
|
19
|
+
})
|
|
20
|
+
.from(users);
|
|
21
|
+
|
|
22
|
+
// Filter by query if provided (case-insensitive partial match on displayName)
|
|
23
|
+
if (params.q) {
|
|
24
|
+
query = query.where(ilike(users.displayName, `%${params.q}%`));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const results = await query.limit(20);
|
|
28
|
+
|
|
29
|
+
// Transform to Lookup format
|
|
30
|
+
return results.map((u) => ({
|
|
31
|
+
id: u.id,
|
|
32
|
+
title: u.displayName,
|
|
33
|
+
subtitle: u.email,
|
|
34
|
+
}));
|
|
35
|
+
},
|
|
36
|
+
}),
|
|
37
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { validateEnvironment } from "@nubase/backend";
|
|
2
|
+
import { loadEnv } from "./helpers/env";
|
|
3
|
+
|
|
4
|
+
// Load environment variables
|
|
5
|
+
loadEnv();
|
|
6
|
+
|
|
7
|
+
// Verify database connectivity before starting the server
|
|
8
|
+
try {
|
|
9
|
+
await validateEnvironment();
|
|
10
|
+
console.log("Preflight check passed: Database connection verified");
|
|
11
|
+
} catch (err) {
|
|
12
|
+
console.error(
|
|
13
|
+
"Preflight check failed:",
|
|
14
|
+
err instanceof Error ? err.message : err,
|
|
15
|
+
);
|
|
16
|
+
console.error("Please ensure the database is running and accessible.");
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|
|
@@ -5,6 +5,7 @@ import { apiEndpoints } from "schema";
|
|
|
5
5
|
import { __PROJECT_NAME_PASCAL__AuthController } from "./auth/__PROJECT_NAME_PASCAL__AuthController";
|
|
6
6
|
import { analyticsDashboard } from "./dashboards/analytics";
|
|
7
7
|
import { ticketResource } from "./resources/ticket";
|
|
8
|
+
import { userResource } from "./resources/user";
|
|
8
9
|
|
|
9
10
|
const apiBaseUrl =
|
|
10
11
|
import.meta.env.VITE_API_BASE_URL || "http://localhost:__BACKEND_PORT__";
|
|
@@ -28,6 +29,7 @@ export const config: NubaseFrontendConfig<typeof apiEndpoints> = {
|
|
|
28
29
|
],
|
|
29
30
|
resources: {
|
|
30
31
|
[ticketResource.id]: ticketResource,
|
|
32
|
+
[userResource.id]: userResource,
|
|
31
33
|
},
|
|
32
34
|
keybindings: defaultKeybindings.extend(),
|
|
33
35
|
apiBaseUrl: apiBaseUrl,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createResource } from "@nubase/frontend";
|
|
2
|
+
import { apiEndpoints } from "schema";
|
|
3
|
+
|
|
4
|
+
export const userResource = createResource("user")
|
|
5
|
+
.withApiEndpoints(apiEndpoints)
|
|
6
|
+
.withLookup({
|
|
7
|
+
onSearch: ({ query, context }) =>
|
|
8
|
+
context.http.lookupUsers({ params: { q: query } }),
|
|
9
|
+
})
|
|
10
|
+
.withViews({});
|
|
@@ -12,12 +12,12 @@
|
|
|
12
12
|
"dev": "turbo run dev",
|
|
13
13
|
"dev:e2e": "turbo run dev dev:e2e",
|
|
14
14
|
"build": "turbo run build",
|
|
15
|
-
"db:up": "
|
|
16
|
-
"db:down": "
|
|
17
|
-
"db:seed": "
|
|
18
|
-
"db:reset": "
|
|
19
|
-
"db:test:up": "
|
|
20
|
-
"db:test:reset": "
|
|
15
|
+
"db:up": "./scripts/check-docker.sh npm run -w backend db:dev:up",
|
|
16
|
+
"db:down": "./scripts/check-docker.sh npm run -w backend db:dev:down",
|
|
17
|
+
"db:seed": "npm run -w backend db:dev:seed",
|
|
18
|
+
"db:reset": "./scripts/check-docker.sh npm run -w backend db:dev:reset",
|
|
19
|
+
"db:test:up": "./scripts/check-docker.sh npm run -w backend db:test:up",
|
|
20
|
+
"db:test:reset": "./scripts/check-docker.sh npm run -w backend db:test:reset",
|
|
21
21
|
"typecheck": "turbo run typecheck",
|
|
22
22
|
"lint": "turbo run lint",
|
|
23
23
|
"lint:fix": "turbo run lint:fix",
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Check if Docker daemon is running before executing database commands
|
|
4
|
+
|
|
5
|
+
if ! docker info > /dev/null 2>&1; then
|
|
6
|
+
echo "Error: Cannot connect to Docker daemon."
|
|
7
|
+
echo ""
|
|
8
|
+
echo "Please ensure Docker is running and try again."
|
|
9
|
+
exit 1
|
|
10
|
+
fi
|
|
11
|
+
|
|
12
|
+
# Execute the command passed as arguments
|
|
13
|
+
exec "$@"
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
patchTicketSchema,
|
|
22
22
|
postTicketSchema,
|
|
23
23
|
} from "./endpoints/ticket";
|
|
24
|
+
import { lookupUsersSchema } from "./endpoints/user";
|
|
24
25
|
|
|
25
26
|
export const apiEndpoints = {
|
|
26
27
|
// Auth
|
|
@@ -38,6 +39,9 @@ export const apiEndpoints = {
|
|
|
38
39
|
patchTicket: patchTicketSchema,
|
|
39
40
|
deleteTicket: deleteTicketSchema,
|
|
40
41
|
|
|
42
|
+
// Users
|
|
43
|
+
lookupUsers: lookupUsersSchema,
|
|
44
|
+
|
|
41
45
|
// Dashboard widgets
|
|
42
46
|
getRevenueChart: getRevenueChartSchema,
|
|
43
47
|
getBrowserStats: getBrowserStatsSchema,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { lookupUsersSchema } from "./lookup-users";
|