MIRROR: javascript for ๐Ÿœ's, a tiny runtime with big ambitions
1
fork

Configure Feed

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

migrate server to the new radix3

+14 -13
+1
examples/server/radix3.js
··· 142 142 this.insertPath(newChild, path, handler, end); 143 143 } 144 144 145 + // if the method is wrong return null instead of undefined 145 146 lookup(path, method = 'GET') { 146 147 const params = {}; 147 148 const fullPath = `${method}#${path}`;
+12 -12
examples/server/server.js
··· 6 6 7 7 const router = new Radix3(); 8 8 9 - router.insert('/', c => c.res.body(`Welcome to Ant ${Ant.version}!`)); 9 + router.get('/', c => c.res.body(`Welcome to Ant ${Ant.version}!`)); 10 10 11 - router.insert('/meow', async c => { 11 + router.get('/meow', async c => { 12 12 return c.res.body(meow); 13 13 }); 14 14 15 - router.insert('/fs/meow', async c => { 15 + router.get('/fs/meow', async c => { 16 16 const file = await readFile(join(import.meta.dirname, 'meow.txt')); 17 17 return c.res.body(file || 'none'); 18 18 }); 19 19 20 - router.insert('/hello', async c => { 20 + router.get('/hello', async c => { 21 21 return c.res.body('Hello, World!'); 22 22 }); 23 23 24 - router.insert('/status', async c => { 24 + router.get('/status', async c => { 25 25 await new Promise(resolve => setTimeout(resolve, 1000)); 26 26 const result = await Promise.resolve('Hello'); 27 27 return c.res.body(`server is responding with ${result}`); 28 28 }); 29 29 30 - router.insert('/users/:id', async c => { 30 + router.get('/users/:id', async c => { 31 31 return c.res.body(`User ID: ${c.params.id}`); 32 32 }); 33 33 34 - router.insert('/users/:id/posts', async c => { 34 + router.get('/users/:id/posts', async c => { 35 35 return c.res.body(`Posts for user: ${c.params.id}`); 36 36 }); 37 37 38 - router.insert('/api/v1/users', async c => { 38 + router.get('/api/v1/users', async c => { 39 39 return c.res.json({ users: [] }); 40 40 }); 41 41 42 - router.insert('/zen', async c => { 42 + router.get('/zen', async c => { 43 43 const response = await fetch('https://api.github.com/zen'); 44 44 return c.res.body(response.body); 45 45 }); 46 46 47 - router.insert('/api/v2/demo', async c => { 47 + router.get('/api/v2/demo', async c => { 48 48 const data = await fetch('https://themackabu.dev/test.json'); 49 49 return c.res.json(data.json()); 50 50 }); 51 51 52 - router.insert('/files/*path', async c => { 52 + router.get('/files/*path', async c => { 53 53 return c.res.html(html`<div>${c.params.path}</div>`); 54 54 }); 55 55 ··· 58 58 59 59 async function handleRequest(req, res) { 60 60 console.log('request:', req.method, req.uri); 61 - const result = router.lookup(req.uri); 61 + const result = router.lookup(req.uri, 'GET'); 62 62 63 63 if (result?.handler) { 64 64 const ctx = { req, res, params: result.params };
+1 -1
meson.build
··· 67 67 build_date = run_command('date', '+%Y-%m-%d', check: true).stdout().strip() 68 68 69 69 version_conf = configuration_data() 70 - version_conf.set('ANT_VERSION', '0.0.6.37') 70 + version_conf.set('ANT_VERSION', '0.0.6.38') 71 71 version_conf.set('ANT_GIT_HASH', git_hash) 72 72 version_conf.set('ANT_BUILD_DATE', build_date) 73 73