TypeScript based developer toolkit for Sonolus servers with Express.js.
- Setup all necessary routes automatically, compliant with Sonolus server specifications.
- Provide handlers to interact with each route.
- Load packs created by sonolus-pack.
npm install @sonolus/express
const sonolus = new Sonolus()
sonolus.load('./pack')
const sonolusShare = new SonolusSpaShare('./public')
const port = 3000
const app = express()
app.use(sonolus.router)
app.use(sonolusShare.router)
app.listen(port, () => {
console.log('Server listening at port', port)
})
Create a Sonolus server.
options.address
: address of server (should not have ending/
).options.fallbackLocale
: fallback locale when user's preferred locale cannot be used.options.configuration
: server configuration.options.upload
: upload options.options[type]
: options for item group,type
can be:post
,playlist
,level
,skin
,background
,effect
,particle
,engine
,replay
, orroom
.options[type].creates
: creates for item group.options[type].searches
: searches for item group.options[type].community.actions
: community actions for item group.
As passed in from constructor(options)
.
As passed in from constructor(options)
.
Configured Express.js router.
Server title.
Server description.
Server banner.
Handler for authentication session.
Handler for authentication.
Handler for requesting server info.
Handler for creating multiplayer room.
Handler for joining multiplayer room.
Item group.
type
can be: post
, playlist
, level
, skin
, background
, effect
, particle
, engine
, replay
, or room
.
Items.
Can be dynamically modified.
Creates.
Searches.
Handler for requesting item info.
Handler for requesting item list.
Handler for creating item.
Pre handler for uploading item.
Handler for uploading item.
Handler for requesting item details.
Handler for submitting item action.
Pre handler for uploading item action.
Handler for uploading item action.
Community actions.
Handler for requesting item community info.
Handler for submitting item community action.
Pre handler for uploading item community action.
Handler for uploading item community action.
Community comment actions.
Handler for requesting item community comment list.
Handler for submitting item community comment action.
Pre handler for uploading item community comment action.
Handler for uploading item community comment action.
Handler for requesting item community details.
Handler for requesting item community record list.
Handler for requesting item community record details.
Load a pack created by sonolus-pack.
path
: file path to the pack.
Add a resource. Returns Srl
which can be used to access the resource.
type
: resource type.data
: data (Buffer
) or file path (string
) to the data.hash
: (optional) hash of the resource, will be calculated automatically when omitted.
Localize text using target and fallback locales.
text
: text to localize.locale
: target locale.
Create a Sonolus SPA share server.
root
: root of static SPA files.
Configured Express.js router.
Create a Sonolus redirect share server.
root
: root of redirect.
Configured Express.js router.
Filter items by keywords.
items
: items.keywords
: keywords.
Paginate items by page and per page size.
items
: items.page
: page.perPage
: per page size, defaults to 20.
Use declaration merging:
declare module '@sonolus/express' {
interface LevelItemModel {
meta: {
// user-defined meta information
}
}
}