exa.js by tux
exa.js is a minimal node.js backend framework that has a strong focus on simplicity, modularity, and convention over configuration.
as if the javascript ecosystem needs another framework... i get it, but please know that this project is the culmination of ~10 years of professional development trying to understand what i/people really need in a framework. this project is the consolidated and cleaned up version of about 30 projects worth of boilerplate patchwork that has been unevenly iterated on and used in some form during this time. i'm certain you'll find use for it, and i certainly will.
# create a new directory for your project
mkdir myproject; cd myproject
# initialize
npx @exajs/core init
# start dev with auto reload
npm run watch
# --or--
# start production
npm start
initializing will create the exa.js template project structure in the current directory. a brief description of this template is below.
-
config
contains amaster.js
configuration file. this is used for project level configuration. for environment level configuration, it's recommended to use a.env
file in the root and transfer relevant env usingprocess.env
inmaster.js
. -
console
contains console scripts that can be invoked withnpm run console <script name>
. see docs for proper format. -
http
contains api logic organized in one or more files. each file contains route definitions, middleware, and handlers. see docs for proper format. -
library
contains user defined library files. this is generally relevant js files for your project that don't fit anywhere else. -
middleware
contains express.js compatible middleware. middleware is configured for use in api logic. see docs for proper format. -
migrations
contains jmig compatible database migrations files. these are used to apply and rollback changes to a database. please see the jmig readme for usage specifics. -
models
contains sequelize.js compatible database model files. to use a different database orm, setdatabase.use = false
inconfig/master.js
which will disable automatic initialization of themodels
folder. see docs for proper format. -
public
contains publicly available static files. in development, this is served withexpress.static()
at base url/public
. in production, this should be served with a normal web server. -
var
contains variable static data, use this to store files that aren't directly used in your project, such as docs, sql files, notes, etc. -
views
contains view templates for traditional non-async frontends. useres.render(path, variables)
instead ofres.send()
in your api logic. -
websocket
contains files that represent websocket connection entrypoints. see docs for proper format.
the most amount of features are enabled by default since none of them clash. to disable a specific feature of your project and replace it with something else, set use: false
for the corresponding key in config/master.js
.
the following features can be disabled if desired:
- console
- http
- models (database)
- public
- views
- websocket
- .env
a.env
file in the root, if present, is evaluated and added to the environment of the running script at the time it is ran. any values placed in here are made available withprocess.env.*
within your code. this is also very helpful if running your project within docker. - dev mode
exa.js runs in production mode by default. doing any of the following things will cause it to run in dev mode:- set
environment.development = true
inconfig/master.js
- set
EXAENV=development
as an environment variable, typically in.env
- set