naidejs 1.0.0 → 1.2.0

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.
@@ -0,0 +1,74 @@
1
+ # Full NAIDE app with all features
2
+
3
+ db "data/"
4
+
5
+ env:
6
+ PORT int default(3000)
7
+ JWT_SECRET str required
8
+
9
+ schema User:
10
+ id auto
11
+ name str required min(2) max(50)
12
+ email str required email
13
+ password str required
14
+ role str default("user")
15
+
16
+ schema Todo:
17
+ id auto
18
+ title str required min(1)
19
+ done bool default(false)
20
+ created timestamp auto
21
+
22
+ server app port PORT:
23
+ cors "*"
24
+ cookie
25
+ auth JWT_SECRET:
26
+ protect "/api/*"
27
+ public "/api/auth/*"
28
+ limit "/api/*" 100 "1m"
29
+ static "/public"
30
+ crud "/api/users" User
31
+ crud "/api/todos" Todo
32
+
33
+ group "/api/v1":
34
+ get "/status":
35
+ ret {version: "1.0", status: "ok"}
36
+
37
+ post "/api/auth/register" (req, res):
38
+ str hashed = hash(req.body.password)
39
+ user = UserStore.create({name: req.body.name, email: req.body.email, password: hashed})
40
+ if user.error:
41
+ ret.status 400 {errors: user.error}
42
+ token = auth.sign({id: user.id, role: user.role})
43
+ ret {token, user: {id: user.id, name: user.name, email: user.email}}
44
+
45
+ post "/api/auth/login" (req, res):
46
+ user = UserStore.where({email: req.body.email})[0]
47
+ if not user:
48
+ ret.status 401 {error: "Invalid credentials"}
49
+ if not verify(req.body.password, user.password):
50
+ ret.status 401 {error: "Invalid credentials"}
51
+ token = auth.sign({id: user.id, role: user.role})
52
+ ret {token}
53
+
54
+ get "/health":
55
+ ret {status: "ok"}
56
+
57
+ get "/":
58
+ ret.html "<h1>Welcome to NAIDE</h1><p>API running.</p>"
59
+
60
+ ws "/chat":
61
+ on "connect":
62
+ send({type: "welcome", msg: "Connected to chat"})
63
+ on "message" (data):
64
+ broadcast(data)
65
+
66
+ error (err, req, res):
67
+ log.error err.message
68
+ ret.status 500 {error: "Internal server error"}
69
+
70
+ every "30m":
71
+ log "cleanup running"
72
+
73
+ watch User.create (event):
74
+ log "new user: {event.data.name}"
@@ -0,0 +1,74 @@
1
+ -- Full NAIDE-X app with all features
2
+
3
+ db "data/"
4
+
5
+ env:
6
+ PORT int default(3000)
7
+ JWT_SECRET str required
8
+
9
+ schema User:
10
+ id auto
11
+ name str required min(2) max(50)
12
+ email str required email
13
+ password str required
14
+ role str default("user")
15
+
16
+ schema Todo:
17
+ id auto
18
+ title str required min(1)
19
+ done bool default(false)
20
+ created timestamp auto
21
+
22
+ $app:PORT
23
+ cors "*"
24
+ cookie
25
+ auth JWT_SECRET:
26
+ protect "/api/*"
27
+ public "/api/auth/*"
28
+ limit "/api/*" 100 "1m"
29
+ static "/public"
30
+ crud "/api/users" User
31
+ crud "/api/todos" Todo
32
+
33
+ group "/api/v1":
34
+ G"/status"
35
+ >{version:"1.0",status:"ok"}
36
+
37
+ P"/api/auth/register"(req,res)
38
+ s:hashed=hash(req.body.password)
39
+ user=UserStore.create({name:req.body.name,email:req.body.email,password:hashed})
40
+ ?user.error
41
+ >.s 400 {errors:user.error}
42
+ token=auth.sign({id:user.id,role:user.role})
43
+ >{token,user:{id:user.id,name:user.name,email:user.email}}
44
+
45
+ P"/api/auth/login"(req,res)
46
+ user=UserStore.where({email:req.body.email})[0]
47
+ ?not user
48
+ >.s 401 {error:"Invalid credentials"}
49
+ ?not verify(req.body.password,user.password)
50
+ >.s 401 {error:"Invalid credentials"}
51
+ token=auth.sign({id:user.id,role:user.role})
52
+ >{token}
53
+
54
+ G"/health"
55
+ >{status:"ok"}
56
+
57
+ G"/"
58
+ >.h "<h1>Welcome to NAIDE</h1>"
59
+
60
+ ws "/chat":
61
+ on "connect":
62
+ send({type:"welcome"})
63
+ on "message" (data):
64
+ broadcast(data)
65
+
66
+ error (err, req, res):
67
+ log.error err.message
68
+ >.s 500 {error:"Internal server error"}
69
+
70
+ every "30m":
71
+ log"cleanup running"
72
+
73
+ watch User.create (event):
74
+ log"new user: {event.data.name}"
package/package.json CHANGED
@@ -1,8 +1,12 @@
1
1
  {
2
2
  "name": "naidejs",
3
- "version": "1.0.0",
4
- "description": "NAIDE - Node AI Development Environment. A language optimized for AI code generation that transpiles to Node.js. Standard mode (~40% fewer tokens) and X mode (~80% fewer tokens).",
3
+ "version": "1.2.0",
4
+ "description": "NAIDE - Node AI Development Environment. AI-specialized language with built-in server, auth, DB, WebSocket, and more — transpiles to Node.js. Standard mode (~40% fewer tokens) and X mode (~80% fewer tokens).",
5
5
  "main": "src/index.js",
6
+ "exports": {
7
+ ".": "./src/index.js",
8
+ "./runtime": "./src/runtime.js"
9
+ },
6
10
  "bin": {
7
11
  "naide": "bin/naide.js"
8
12
  },
@@ -31,15 +35,19 @@
31
35
  "claude",
32
36
  "chatgpt",
33
37
  "naide",
34
- "dsl"
38
+ "dsl",
39
+ "express",
40
+ "api",
41
+ "backend",
42
+ "server"
35
43
  ],
36
44
  "author": "pirikari.sena@gmail.com",
37
45
  "license": "MIT",
38
46
  "repository": {
39
47
  "type": "git",
40
- "url": "https://github.com/pirikari/naide"
48
+ "url": "https://github.com/irxk/naide"
41
49
  },
42
- "homepage": "https://github.com/pirikari/naide#readme",
50
+ "homepage": "https://github.com/irxk/naide#readme",
43
51
  "engines": {
44
52
  "node": ">=18.0.0"
45
53
  }