A Deno-powered backend service for Plants vs. Zombies: MODDED. [Read-only GitHub mirror] docs.pvzm.net
express typescript expressjs plant deno jspvz pvzm game online backend plants-vs-zombies zombie javascript plants modded vs plantsvszombies openapi pvz noads
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Format "replace memorystore" Original commit: https://github.com/ROBlNET13/pvzm-backend/commit/dfdfa9ad7cf04711b9ab4f4a4e98661d4e528843

Co-authored-by: ClaytonTDM <clay@clay.rip>

+64 -66
+59 -59
README.md
··· 92 92 - **Code:** 201 93 93 - **Content:** 94 94 95 - ```json 96 - { 97 - "id": 123, 98 - "name": "Level Name", 99 - "author": "Author Name", 100 - "created_at": 1714680000, 101 - "sun": 100, 102 - "is_water": true, 103 - "version": 3 104 - } 105 - ``` 95 + ```json 96 + { 97 + "id": 123, 98 + "name": "Level Name", 99 + "author": "Author Name", 100 + "created_at": 1714680000, 101 + "sun": 100, 102 + "is_water": true, 103 + "version": 3 104 + } 105 + ``` 106 106 107 - Note: `is_water` is stored as `0/1` in the database and is returned as `0/1` in list/detail endpoints. 107 + Note: `is_water` is stored as `0/1` in the database and is returned as `0/1` in list/detail endpoints. 108 108 109 109 - **Error Responses:** 110 110 - **Code:** 400 ··· 136 136 - **Code:** 200 137 137 - **Content:** 138 138 139 - ```json 140 - { 141 - "levels": [ 142 - { 143 - "id": 123, 144 - "name": "Level Name", 145 - "author": "Author Name", 146 - "created_at": 1714680000, 147 - "sun": 100, 148 - "is_water": 1, 149 - "favorites": 5, 150 - "plays": 10, 151 - "difficulty": 7, 152 - "thumbnail": [[0, 10, 10, 40, 40, 1]], 153 - "version": 3 154 - } 155 - ], 156 - "pagination": { 157 - "total": 50, 158 - "page": 1, 159 - "limit": 10, 160 - "pages": 5 161 - } 162 - } 163 - ``` 139 + ```json 140 + { 141 + "levels": [ 142 + { 143 + "id": 123, 144 + "name": "Level Name", 145 + "author": "Author Name", 146 + "created_at": 1714680000, 147 + "sun": 100, 148 + "is_water": 1, 149 + "favorites": 5, 150 + "plays": 10, 151 + "difficulty": 7, 152 + "thumbnail": [[0, 10, 10, 40, 40, 1]], 153 + "version": 3 154 + } 155 + ], 156 + "pagination": { 157 + "total": 50, 158 + "page": 1, 159 + "limit": 10, 160 + "pages": 5 161 + } 162 + } 163 + ``` 164 164 165 165 - **Error Response:** 166 166 - **Code:** 401 ··· 178 178 - **Code:** 200 179 179 - **Content:** 180 180 181 - ```json 182 - { 183 - "id": 123, 184 - "name": "Level Name", 185 - "author": "Author Name", 186 - "created_at": 1714680000, 187 - "sun": 100, 188 - "is_water": 1, 189 - "favorites": 5, 190 - "plays": 10, 191 - "difficulty": 7, 192 - "thumbnail": null, 193 - "version": 3 194 - } 195 - ``` 181 + ```json 182 + { 183 + "id": 123, 184 + "name": "Level Name", 185 + "author": "Author Name", 186 + "created_at": 1714680000, 187 + "sun": 100, 188 + "is_water": 1, 189 + "favorites": 5, 190 + "plays": 10, 191 + "difficulty": 7, 192 + "thumbnail": null, 193 + "version": 3 194 + } 195 + ``` 196 196 197 197 - **Error Responses:** 198 198 - **Code:** 400 ··· 281 281 - **Code:** 200 282 282 - **Content:** 283 283 284 - ```json 285 - { 286 - "turnstileEnabled": true, 287 - "turnstileSiteKey": "0x0000000000000000000000", 288 - "moderationEnabled": true 289 - } 290 - ``` 284 + ```json 285 + { 286 + "turnstileEnabled": true, 287 + "turnstileSiteKey": "0x0000000000000000000000", 288 + "moderationEnabled": true 289 + } 290 + ``` 291 291 292 292 ## Environment Variables 293 293
+5 -7
modules/server/auth.ts
··· 17 17 sess TEXT NOT NULL, 18 18 expire INTEGER NOT NULL 19 19 ); 20 - CREATE INDEX IF NOT EXISTS idx_sessions_expire ON sessions(expire);`, 20 + CREATE INDEX IF NOT EXISTS idx_sessions_expire ON sessions(expire);` 21 21 ); 22 22 } 23 23 ··· 43 43 get(sid: string, cb: (err?: any, session?: any | null) => void) { 44 44 try { 45 45 const nowMs = Date.now(); 46 - const row = this.db.prepare("SELECT sess, expire FROM sessions WHERE sid = ?").get(sid) as 47 - | { sess: string; expire: number } 48 - | undefined; 46 + const row = this.db.prepare("SELECT sess, expire FROM sessions WHERE sid = ?").get(sid) as { sess: string; expire: number } | undefined; 49 47 if (!row) return cb(null, null); 50 48 if (row.expire < nowMs) { 51 49 this.db.prepare("DELETE FROM sessions WHERE sid = ?").run(sid); ··· 62 60 const nowMs = Date.now(); 63 61 this.cleanupExpired(nowMs); 64 62 const expire = this.computeExpireMs(sess); 65 - this.db.prepare( 66 - "INSERT INTO sessions (sid, sess, expire) VALUES (?, ?, ?) ON CONFLICT(sid) DO UPDATE SET sess=excluded.sess, expire=excluded.expire", 67 - ).run(sid, JSON.stringify(sess), expire); 63 + this.db 64 + .prepare("INSERT INTO sessions (sid, sess, expire) VALUES (?, ?, ?) ON CONFLICT(sid) DO UPDATE SET sess=excluded.sess, expire=excluded.expire") 65 + .run(sid, JSON.stringify(sess), expire); 68 66 return cb(null); 69 67 } catch (err) { 70 68 return cb(err);