entix-core
v0.0.5
Published
Entix-core speeds up the development of Koa APIs by combining the benefits of several technologies to provide basic CRUD capability straight out of the box.
Downloads
6
Readme
entix-core
Entix-core speeds up the development of Koa APIs by combining the benefits of several technologies to provide basic CRUD capability straight out of the box.
Motivation
When developing server-side applications from scratch, writing basic CRUD operations takes a significant amount of time. To that end, the Entix Ecosystem was created to provide developers with tooling that eliminates the need for them to write generic code, allowing them to focus on more difficult aspects of their project. Entix-Core, as the name implies, is at the core unit of all Entix-Projects responsible for loading and running Entix projects.
Getting Started
- $ npm i joi kcors knex koa koa2-formidable lodash objection pluralize sqlite3
index.js
const app = new (require('koa'))
const cors = require('kcors')
const bodyparse = require('koa2-formidable')
const config = require('./config')
const projectPath = require('path').resolve(__dirname, 'src')
global.entix = require('entix-core')(projectPath)
app.use(bodyparse(config.bodyParser))
app.use(cors())
app.use(entix.errodHandler(entix.services.handler))
app.use(entix.router.routes())
app.listen(config.server.port, () => {
console.log('running at:', config.serverUrl)
})
config.js
const { Config } = require('entix-core')
const config = {
server: {
protocol: 'http',
hostname: 'localhost',
port: 3000,
},
crypto: {
secret: '{{cryptoSecret}}',
algorithm: '{{cryptoAlgorithm}}'
},
ws: {
cors: { origin: '*' }
},
bodyParser: {
multipart: true,
maxFileSize: 5000 * 1024 * 1024
},
jwt: {
access: {
secret: '{{accessTokenSecret}}',
options: {
expiresIn: '{{accessTokenExpiry}}'
}
},
refresh: {
secret: '{{refreshTokenSecret}}',
options: {
expiresIn: '{{refreshTokenExpiry}}'
}
},
},
}
module.exports = new Config(config)
knexfile.js
module.exports = {
/* SQLITE */
development: {
client: 'sqlite3',
useNullAsDefault: true,
connection: {
filename: './store/store.sqlite3'
},
seeds: {
directory: './store/seeds'
},
migrations: {
tableName: 'knex_migrations',
directory: './store/migrations'
},
pool: {
min: 2,
max: 10
},
},
/* POSTGRES */
// development: {
// client: '{{dbClient}}',
// connection: {
// host: '{{dbHost}}',
// port: '{{dbPort}}',
// user: '{{dbUser}}',
// password: '{{dbPassword}}',
// database: '{{dbName}}',
// },
// seeds: {
// directory: './src/db/seeds'
// },
// migrations: {
// tableName: 'knex_migrations',
// directory: './src/db/migrations'
// },
// pool: {
// min: 2,
// max: 10
// },
// },
};
Entix Ecosystem
Currently, the Entix Ecosystem consists of two projects:
- Entix Core: loads and runs Entix projects.
- Entix CLI: generates template Entix projects.
Structure of an Entix Project
├── README.md
├── config.js
├── index.js
├── knexfile.js
├── package-lock.json
├── package.json
├── src
| ├── api
| ├── middleware
| └── services
└── store
├── migrations
├── seeds
└── store.sqlite3
directory: 7 file: 7