cpd_server
v0.0.9
Published
Installez le module ``` npm i cpd_server ```
Downloads
6
Maintainers
Readme
Installez le module
npm i cpd_server
Avec express
const epxress = require('express')
const fs = require('fs')
const cpd_server = require('cpd_server')
const app = epxress()
const PORT = 8080
//DEFINE WEBSITE URL
cpd_server.server.setURL = "http://localhost:8080" //You're server ip address or domain address
app.get('/modpack/:versions', (req, res) => {
if (fs.existsSync(`${__dirname}/update/${req.params.versions}`)) {
var list = cpd_server.crawl(`update/${req.params.versions}/`)
cpd_server.saveJson(`${__dirname}/public/${req.params.versions}.json`, list)
res.sendFile(`${__dirname}/public/${req.params.versions}.json`)
} else {
res.json({ error : { code: 404, message: 'this modpack does not appear in the modpack folder'}})
}
})
app.use('/update', epxress.static(`${__dirname}/update`))
app.use('/public', epxress.static(`${__dirname}/public`))
app.listen(PORT, () => {
console.log('Server listen on port : ' + PORT);
})
Exemple d'architecture :
[-] Root foler
|- node_module
|+ public
-| VERSIONS-1.json
-| VERSIONS-2.json
-| VERSIONS-3.json
-| ...
|+ update
|+ VERSIONS-1
|- config/*
|- mods/*
|- forge-VERSIONS-1.jar
|+ VERSIONS-2
|- config/*
|- mods/*
|- forge-VERSIONS-2.jar
|+ VERSIONS-3
|- config/*
|- mods/*
|- forge-VERSIONS-3.jar
|- package-lock.json
|- package.json
|- server.js
[/!\ Indisponnible pour le moment] Uniquement le serveur
suivez cs troix étape
1: git clone url dossier
2: cd dossier && npm i
3: npm start