Skip to content

rongfengliang/ringojs-module-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ringojs module demo

how to work with module

user filename

  • app/app.js
exports.app= {
  name:"dalong",
  age:33,
  type:"app"
}

use:

const {app} =require("./app")
exports.app=app;

  • use app/package.json

{
  "version": "1.0.0",
  "main": "app.js", // define main location 
  "license": "MIT"
}

  • user default app/index.js
const {app} =require("./app")
exports.app=app;

  • outside import module

index.js

const {app}  = require("./app")
const {user} = require("./user")
const boot = require("./boot")
console.dir(user)
console.dir(app)
console.dir(boot.run())

run module with rp && docker

base image dalongrong/ringojs-docker:1.2.1-local include rp

use stick package

  • build && run
docker-compose build

docker-compose up -d
  • access
open http://localhost:8080

use java jar lib

use addToClasspath add jar libs

call

 // with package name
var hashids = new org.hashids.Hashids("this is my salt");
var hash = hashids.encode(12345);
return response.html(hash)