Gathering detailed insights and metrics for @neumatter/record
Gathering detailed insights and metrics for @neumatter/record
Gathering detailed insights and metrics for @neumatter/record
Gathering detailed insights and metrics for @neumatter/record
npm install @neumatter/record
Typescript
Module System
Node Version
NPM Version
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
2
Module for scanning file directories. Can configure automatic routes with middleware.
1npm i @neumatter/record
1import Record from '@neumatter/record' 2import nodePath from 'path' 3 4const record = await Record.build({ 5 path: nodePath.resolve('./') 6}) 7 8// Returns 9const NeuRecord = { 10 path: '/Users/dev/example', 11 basepath: '/', 12 name: '', 13 previous: null, 14 files: [ 15 { 16 path: '/Users/dev/example/session.js', 17 basepath: '/', 18 container: 'routes', 19 isDot: false, 20 name: 'session', 21 ext: '.js', 22 subext: null, 23 customName: null 24 }, 25 { 26 path: '/Users/dev/example/nextdir/index.js', 27 basepath: '/nextdir', 28 container: 'nextdir', 29 isDot: false, 30 name: 'index', 31 ext: '.js', 32 subext: null, 33 customName: '' 34 } 35 ], 36 middleware: [], 37 subrecords: [], 38 map: { 39 profile: { 40 path: '/Users/dev/example/nextdir', 41 name: 'profile', 42 files: ['Array'], 43 subrecords: {} 44 } 45 }, 46 cwd: '/Users/dev/example' 47}
1import Record from '@neumatter/record' 2 3const record = await Record.readdir({ 4 path: process.cwd(), 5 allow: ['.json'] 6}) 7 8// Returns 9const NeuRecord = { 10 path: '/Users/dev/neujs/tests/basic', 11 basepath: '/', 12 name: '', 13 previous: null, 14 files: NeuPack { 15 keys: [ '/basic/json', '/basic/neu', '/basic/record' ], 16 data: { 17 '/basic/json': [Spec], 18 '/basic/neu': [Spec], 19 '/basic/record': [Spec] 20 }, 21 id: 'pathName' 22 }, 23 subrecords: NeuPack { 24 keys: [ '/public', '/schemas', '/server' ], 25 data: { 26 '/public': [NeuRecord], 27 '/schemas': [NeuRecord], 28 '/server': [NeuRecord] 29 }, 30 id: 'pathName' 31 }, 32 map: NeuPack { keys: [], data: {}, id: 'path' }, 33 cwd: '/Users/dev/neujs/tests/basic' 34}
1import Record from '@neumatter/record' 2import nodePath from 'path' 3 4const record = await Record.build({ 5 path: nodePath.resolve('./') 6}) 7 8// returns Array<modules> 9const modules = await record.importModules('default') 10 11// NeuRecord.files.all: loop through files Async 12await record.files.all(async spec => { 13 const specModule = await spec.import('default') 14 // do something with <specModule> 15}) 16 17// NeuRecord.files.each: loop through files Sync 18record.files.each(spec => { 19 const specModule = spec.import('default') 20 spec.import('default') 21 .then(specModule => { 22 // do something with <specModule> 23 }) 24 .catch(err => { 25 // error 26 }) 27}) 28 29// imports Array<module.default> and calls the callback on each module 30await record.autoRoutes((router) => { 31 const { path, module, middleware } = router 32 if (middleware) { 33 app.use(path, middleware, module) 34 } else { 35 app.use(path, module) 36 } 37})
1import Record from '@neumatter/record' 2 3// default options 4const record = await Record.build({ 5 path: process.cwd(), 6 basepath: '/', 7 name: '', 8 middleware: false, 9 ignore: [ 10 '.git', 11 'node_modules' 12 ], 13 allow: [ 14 '.js', 15 '.mjs', 16 '.cjs' 17 ], 18 ignoreDots: true, 19 mergeFiles: true, 20 replacer: [ 21 { 22 key: 'index', 23 value: '' 24 } 25 ] 26})
No vulnerabilities found.
No security vulnerabilities found.