create-sprint 0.0.56 → 0.0.58

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.
@@ -117,35 +117,13 @@ export default defineConfig({
117
117
  export function getMainFile(language) {
118
118
  if (language === "typescript") {
119
119
  return `import Sprint from "sprint-es";
120
- import homeRouter from "./routes/home";
121
- import adminRouter from "./routes/admin";
122
- import authInternalMiddleware from "./middlewares/auth.internal";
123
- import authUserMiddleware from "./middlewares/auth.user";
124
120
 
125
121
  const app = new Sprint();
126
-
127
- app.use(authUserMiddleware);
128
- app.use(authInternalMiddleware);
129
- app.route("/", homeRouter);
130
- app.route("/admin", adminRouter);
131
-
132
- app.listen();
133
122
  `;
134
123
  }
135
124
  return `import Sprint from "sprint-es";
136
- import homeRouter from "./routes/home.js";
137
- import adminRouter from "./routes/admin.js";
138
- import authInternalMiddleware from "./middlewares/auth.internal.js";
139
- import authUserMiddleware from "./middlewares/auth.user.js";
140
125
 
141
126
  const app = new Sprint();
142
-
143
- app.use(authUserMiddleware);
144
- app.use(authInternalMiddleware);
145
- app.route("/", homeRouter);
146
- app.route("/admin", adminRouter);
147
-
148
- app.listen();
149
127
  `;
150
128
  }
151
129
  export function getHomeRoute(language) {
@@ -360,13 +338,13 @@ export const jwtGenerateSchema = defineRouteSchema({
360
338
  }
361
339
  export function getInternalAuthMiddleware(language) {
362
340
  if (language === "typescript") {
363
- return `import { defineMiddleware } from "sprint-es";
341
+ return `import { defineMiddleware, SprintRequest, SprintResponse, NextFunction } from "sprint-es";
364
342
 
365
343
  export default defineMiddleware({
366
344
  name: "adminAuth",
367
345
  priority: 10,
368
346
  include: "/admin/**",
369
- handler: (req, res, next) => {
347
+ handler: (req: SprintRequest, res: SprintResponse, next: NextFunction) => {
370
348
  const auth = req.sprint.getAuthorization();
371
349
  if (!auth) return res.status(401).json({ error: "No authorization header" });
372
350
 
@@ -400,7 +378,7 @@ export default defineMiddleware({
400
378
  }
401
379
  export function getUserAuthMiddleware(language) {
402
380
  if (language === "typescript") {
403
- return `import { defineMiddleware } from "sprint-es";
381
+ return `import { defineMiddleware, SprintRequest, SprintResponse, NextFunction } from "sprint-es";
404
382
  import { verifyEncrypted, getJwtFromEnv } from "sprint-es/jwt";
405
383
 
406
384
  const { publicKey, encryptionSecret } = getJwtFromEnv();
@@ -410,7 +388,7 @@ export default defineMiddleware({
410
388
  priority: 10,
411
389
  include: "/**",
412
390
  exclude: "/admin/**",
413
- handler: (req, res, next) => {
391
+ handler: (req: SprintRequest, res: SprintResponse, next: NextFunction) => {
414
392
  const auth = req.sprint.getAuthorization();
415
393
  if (!auth) return res.status(401).json({ error: "No authorization header" });
416
394
 
package/dist/index.js CHANGED
@@ -68,15 +68,15 @@ export async function runCLI(args) {
68
68
  else if (!options.skipPrompts) {
69
69
  installDeps = await p.confirm({ message: "Install dependencies now?", initialValue: true });
70
70
  }
71
- const npmCmd = process.platform === "win32" ? "npm.cmd" : "npm";
72
71
  if (installDeps) {
73
72
  const s2 = p.spinner();
74
73
  s2.start("Installing dependencies");
75
74
  try {
76
75
  await new Promise((resolve, reject) => {
77
- const child = spawn(npmCmd, ["install"], {
76
+ const child = spawn("npm", ["install"], {
78
77
  cwd: targetDir,
79
- stdio: "inherit"
78
+ stdio: "inherit",
79
+ shell: true
80
80
  });
81
81
  child.on("close", (code) => {
82
82
  if (code === 0)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-sprint",
3
- "version": "0.0.56",
3
+ "version": "0.0.58",
4
4
  "description": "Create a new Sprint API project",
5
5
  "type": "module",
6
6
  "bin": {
package/src/generators.ts CHANGED
@@ -131,36 +131,14 @@ export default defineConfig({
131
131
  export function getMainFile(language: string) {
132
132
  if (language === "typescript") {
133
133
  return `import Sprint from "sprint-es";
134
- import homeRouter from "./routes/home";
135
- import adminRouter from "./routes/admin";
136
- import authInternalMiddleware from "./middlewares/auth.internal";
137
- import authUserMiddleware from "./middlewares/auth.user";
138
134
 
139
135
  const app = new Sprint();
140
-
141
- app.use(authUserMiddleware);
142
- app.use(authInternalMiddleware);
143
- app.route("/", homeRouter);
144
- app.route("/admin", adminRouter);
145
-
146
- app.listen();
147
136
  `;
148
137
  }
149
138
 
150
139
  return `import Sprint from "sprint-es";
151
- import homeRouter from "./routes/home.js";
152
- import adminRouter from "./routes/admin.js";
153
- import authInternalMiddleware from "./middlewares/auth.internal.js";
154
- import authUserMiddleware from "./middlewares/auth.user.js";
155
140
 
156
141
  const app = new Sprint();
157
-
158
- app.use(authUserMiddleware);
159
- app.use(authInternalMiddleware);
160
- app.route("/", homeRouter);
161
- app.route("/admin", adminRouter);
162
-
163
- app.listen();
164
142
  `;
165
143
  }
166
144
 
@@ -381,13 +359,13 @@ export const jwtGenerateSchema = defineRouteSchema({
381
359
 
382
360
  export function getInternalAuthMiddleware(language: string) {
383
361
  if (language === "typescript") {
384
- return `import { defineMiddleware } from "sprint-es";
362
+ return `import { defineMiddleware, SprintRequest, SprintResponse, NextFunction } from "sprint-es";
385
363
 
386
364
  export default defineMiddleware({
387
365
  name: "adminAuth",
388
366
  priority: 10,
389
367
  include: "/admin/**",
390
- handler: (req, res, next) => {
368
+ handler: (req: SprintRequest, res: SprintResponse, next: NextFunction) => {
391
369
  const auth = req.sprint.getAuthorization();
392
370
  if (!auth) return res.status(401).json({ error: "No authorization header" });
393
371
 
@@ -422,7 +400,7 @@ export default defineMiddleware({
422
400
 
423
401
  export function getUserAuthMiddleware(language: string) {
424
402
  if (language === "typescript") {
425
- return `import { defineMiddleware } from "sprint-es";
403
+ return `import { defineMiddleware, SprintRequest, SprintResponse, NextFunction } from "sprint-es";
426
404
  import { verifyEncrypted, getJwtFromEnv } from "sprint-es/jwt";
427
405
 
428
406
  const { publicKey, encryptionSecret } = getJwtFromEnv();
@@ -432,7 +410,7 @@ export default defineMiddleware({
432
410
  priority: 10,
433
411
  include: "/**",
434
412
  exclude: "/admin/**",
435
- handler: (req, res, next) => {
413
+ handler: (req: SprintRequest, res: SprintResponse, next: NextFunction) => {
436
414
  const auth = req.sprint.getAuthorization();
437
415
  if (!auth) return res.status(401).json({ error: "No authorization header" });
438
416
 
package/src/index.ts CHANGED
@@ -103,16 +103,15 @@ export async function runCLI(args: string[]) {
103
103
  installDeps = await p.confirm({ message: "Install dependencies now?", initialValue: true }) as boolean;
104
104
  }
105
105
 
106
- const npmCmd = process.platform === "win32" ? "npm.cmd" : "npm";
107
-
108
106
  if (installDeps) {
109
107
  const s2 = p.spinner();
110
108
  s2.start("Installing dependencies");
111
109
  try {
112
110
  await new Promise<void>((resolve, reject) => {
113
- const child = spawn(npmCmd, ["install"], {
111
+ const child = spawn("npm", ["install"], {
114
112
  cwd: targetDir,
115
- stdio: "inherit"
113
+ stdio: "inherit",
114
+ shell: true
116
115
  });
117
116
  child.on("close", (code) => {
118
117
  if (code === 0) resolve();