maxserver 0.0.4 → 0.0.5

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.
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "maxserver",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "Node server setup based fastify",
5
5
  "author": "Max Matinpalo",
6
6
  "type": "module",
@@ -9,10 +9,6 @@
9
9
  "maxserver": "bin/init.js",
10
10
  "maxserver-watcher": "bin/watcher.js"
11
11
  },
12
- "files": [
13
- "src",
14
- "README.mde"
15
- ],
16
12
  "dependencies": {
17
13
  "@fastify/cookie": "^11.0.2",
18
14
  "@fastify/cors": "^11.2.0",
package/templates/env ADDED
@@ -0,0 +1,24 @@
1
+ # Environment
2
+ NODE_ENV = development
3
+
4
+ # Server
5
+ PORT = 3000
6
+
7
+ # CORS(prod only, ignored in dev)
8
+ # CORS_ORIGIN = https://app.example.com
9
+
10
+ # JWT;
11
+ JWT_SECRET = supersecretkey
12
+
13
+ # MongoDB;
14
+ # MONGODB_URI = mongodb://127.0.0.1:27017/testdb
15
+
16
+ # Static files
17
+ # STATIC_DIR =./ public
18
+
19
+ # API Docs in production
20
+ DOCS = 1
21
+
22
+ # Optional HTTPS(direct TLS, no nginx)
23
+ # TLS_KEY = /etc/ssl / private / server.key
24
+ # TLS_CERT = /etc/ssl / certs / server.crt;
@@ -0,0 +1 @@
1
+ node_modules
@@ -0,0 +1,14 @@
1
+ {
2
+ "name": "__NAME__",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "server.js",
6
+ "scripts": {
7
+ "start": "node server.js",
8
+ "dev": "maxserver-watcher"
9
+ },
10
+ "type": "module",
11
+ "dependencies": {
12
+ "maxserver": "^0.0.0"
13
+ }
14
+ }
@@ -0,0 +1,10 @@
1
+ import maxserver from "@max-matinpalo/maxserver";
2
+
3
+ const server = await maxserver();
4
+
5
+ await server.listen({
6
+ port: Number(process.env.PORT || 3000),
7
+ });
8
+
9
+ console.log("Server running at ", server.getAddress());
10
+ export default server;
@@ -0,0 +1,11 @@
1
+ // POST /hello
2
+
3
+ export default async function handler(req, rep) {
4
+
5
+ console.log("POST /hello");
6
+
7
+ return {
8
+ message: `Hello ${req.body.name}`,
9
+ user: req.user || null,
10
+ };
11
+ }
@@ -0,0 +1,34 @@
1
+ export const schema = {
2
+ tags: ["Test"],
3
+ summary: "Create greeting",
4
+ description: "Accepts a name and returns a greeting.",
5
+
6
+ body: {
7
+ type: "object",
8
+ required: ["name"],
9
+ properties: {
10
+ name: {
11
+ type: "string",
12
+ example: "Max",
13
+ },
14
+ },
15
+ },
16
+
17
+ response: {
18
+ 200: {
19
+ type: "object",
20
+ properties: {
21
+ message: {
22
+ type: "string",
23
+ example: "Hello Max",
24
+ },
25
+ user: {
26
+ type: "object",
27
+ example: {
28
+ userId: "64f1c2e9b1a2c3d4e5f67890",
29
+ },
30
+ },
31
+ },
32
+ },
33
+ },
34
+ };
@@ -0,0 +1,8 @@
1
+ // GET /hello
2
+
3
+ export default async function handler(req, rep) {
4
+
5
+ console.log("GET /hello");
6
+
7
+ return { message: `Hello`, };
8
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "handler": {
3
+ "prefix": "handler",
4
+ "body": [
5
+ "// ${1|GET, POST, PUT, PATCH, DELETE|} /$2",
6
+ "",
7
+ "export default async function ${TM_FILENAME_BASE}(req, res) {",
8
+ "",
9
+ "\tconst db = this.mongo.db;",
10
+ "\tconst userId = req.user.userid;",
11
+ "",
12
+ "\t$0",
13
+ "",
14
+ "\treturn res.send({msg: \"${TM_FILENAME_BASE}\"});",
15
+ "}"
16
+ ]
17
+ }
18
+ }
@@ -0,0 +1,23 @@
1
+ // Comment task in to autostart server on dir open
2
+ /*
3
+
4
+
5
+ {
6
+ "version": "1.0.0",
7
+ "tasks": [
8
+ {
9
+ "label": "devserver 📟",
10
+ "type": "shell",
11
+ "command": "npm run dev",
12
+ "presentation": {
13
+ "reveal": "always",
14
+ "panel": "dedicated"
15
+ },
16
+ "runOptions": {
17
+ "runOn": "folderOpen"
18
+ }
19
+ }
20
+ ]
21
+ }
22
+
23
+ */