Skip to content
Chris Eadie edited this page Jun 14, 2020 · 2 revisions

Welcome to the JSNet wiki!

How to use This project only has one dependency which is nunjucks for templating in html document This project follows the MVC framework Each controller is responsible for rendering a view

To create a new view add a new controller to the Controllers folder e.g ./Controllers/about.js within this js file you will create a new class and export it as a module using commonjs module exports

Next you will need to give this file a method which can be named what ever you like as JSNet will parse the url in order to find the method so if you create a method in the about class call team() then to access this method the url will look like "/about/team".

Once this has been created it will needs a return type, to return a page use "View" which can be required in from the core file. You must pass a file path to this relative to the view folder anything at the root of view can be passed in as a string. You must append the filetype being serve e.g, .html or .njk if you are using nunjucks templates

Once this is done you can run the server using npm run server or if you have nodemon installed npm run devserver if you then navigate to this page in a browser you will find your method serving your page

Clone this wiki locally