samsun 🌃
Samsun is a free and open source Backend server framework for complex, scalable or basic functional servers for applications.
Samsun contains many features that will shorten the development time for your server. Like:
- File based route
- Error handlers
- No config needed
- Extensible with plugins
- Hot refresh
- And more...
Getting Started
You can start your project by downloading Samsun and Samsu.
npm install samsum samsu
What you need to do next is to create files and define defult exported functions for them.
The value returned by the function will be sent automatically.
index.js:
export default function (req, res) {
return 'Hello from server!'
}
Development
To start a server with hot refresh and error messages, simply use the samsu
command to start a test server.
samsu
If you want to change anything related to the server or many other things in the development section, you can create a config file.
samsun.config.js:
import { defineConfig } from 'samsun'
export default defineConfig({
server: {
port: 5555
}
})
You can also use the samsu --config=(config)
command to use different config files in different situations.
samsun.config.prod.js:
import { defineConfig } from 'samsun'
export default defineConfig({
server: {
port: 3000
}
})
samsu --config=samsun.config.prod.js
Restful API
Samsun is great for building complex APIs. Instead of defining the route of many files one by one, just name them.
api/v1.js:
export default function (req, res) {
return {
status: 'ok'
}
}
When you go to route /api/v1
a json like this will be returned:
{
"status": "ok"
}
Plugins
You can change the output with the defineConfig
function, or by specifying a plugin you downloaded from npm in the config file.
import { defineConfig } from 'samsun'
import myPlugin from 'samsun-plugin-myPlugin'
export default defineConfig({
plugins: [myPlugin()]
})
We will explain this in more detail when we create a documentation site.
License
MIT