@notation/cli 0.4.0 → 0.4.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/dist/index.js CHANGED
@@ -140,7 +140,7 @@ Creating app from template...`);
140
140
  });
141
141
  console.log("\nApp ready! To get started run:\n");
142
142
  console.log(`\u279C cd ${appName}`);
143
- console.log(`\u279C npx notation compile`);
143
+ console.log(`\u279C ${getPmRunCommand(packageManager)} viz`);
144
144
  }
145
145
  function getPmInstallCommand(pm) {
146
146
  switch (pm) {
@@ -154,6 +154,18 @@ function getPmInstallCommand(pm) {
154
154
  return "npm install";
155
155
  }
156
156
  }
157
+ function getPmRunCommand(pm) {
158
+ switch (pm) {
159
+ case "yarn":
160
+ return "yarn";
161
+ case "pnpm":
162
+ return "pnpm";
163
+ case "bun":
164
+ return "bun";
165
+ default:
166
+ return "npm run";
167
+ }
168
+ }
157
169
 
158
170
  // src/index.ts
159
171
  program.command("create").argument("[appName]", "app name", "notation-starter").description("Create Notation App").action(async (appName) => {
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@notation/cli",
4
- "version": "0.4.0",
4
+ "version": "0.4.2",
5
5
  "files": [
6
- "dist"
6
+ "dist",
7
+ "templates"
7
8
  ],
8
9
  "bin": {
9
10
  "notation": "dist/index.js"
@@ -0,0 +1,7 @@
1
+ {
2
+ "private": true,
3
+ "name": "notation-starter",
4
+ "scripts": {
5
+ "viz": "notation viz src/api.ts"
6
+ }
7
+ }
@@ -0,0 +1,8 @@
1
+ import { api, router } from "@notation/aws/api-gateway";
2
+ import { getTodos, getTodoCount } from "./todos/todos.fn";
3
+
4
+ const todoApi = api({ name: "todo-api" });
5
+ const todoRouter = router(todoApi);
6
+
7
+ todoRouter.get("/todos", getTodos);
8
+ todoRouter.get("/todos/count", getTodoCount);
@@ -0,0 +1,19 @@
1
+ import type { LambdaConfig } from "@notation/aws/lambda.fn";
2
+ import { handle, json } from "@notation/aws/lambda.fn";
3
+ import { api } from "./utils";
4
+
5
+ const todos = await api.get<any[]>("/todos");
6
+
7
+ export const getTodos = handle.apiRequest(() => {
8
+ return json(todos);
9
+ });
10
+
11
+ export const getTodoCount = handle.apiRequest(() => {
12
+ return json(todos.length);
13
+ });
14
+
15
+ export const config: LambdaConfig = {
16
+ service: "aws/lambda",
17
+ timeout: 5,
18
+ memory: 64,
19
+ };
@@ -0,0 +1,6 @@
1
+ export const api = {
2
+ get: async <T = any>(path: string) => {
3
+ const res = await fetch(`https://jsonplaceholder.typicode.com${path}`);
4
+ return res.json() as Promise<T>;
5
+ },
6
+ };
@@ -0,0 +1,27 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "display": "Default",
4
+ "compilerOptions": {
5
+ "lib": ["esnext"],
6
+ "module": "esnext",
7
+ "target": "esnext",
8
+
9
+ "moduleResolution": "bundler",
10
+ "noEmit": true,
11
+
12
+ "composite": false,
13
+ "declaration": true,
14
+ "declarationMap": true,
15
+ "forceConsistentCasingInFileNames": true,
16
+ "inlineSources": false,
17
+ "isolatedModules": true,
18
+ "noUnusedLocals": false,
19
+ "noUnusedParameters": false,
20
+ "preserveWatchOutput": true,
21
+ "skipDefaultLibCheck": true,
22
+ "skipLibCheck": true,
23
+ "strict": true,
24
+ "strictNullChecks": true
25
+ },
26
+ "exclude": ["node_modules"]
27
+ }