Skip to content
This repository has been archived by the owner on Aug 28, 2021. It is now read-only.

Commit

Permalink
Merge pull request #171 from speckleworks/jn-mask
Browse files Browse the repository at this point in the history
fix(version): correctly displays version from git tag if possible
  • Loading branch information
didimitrie authored Nov 21, 2019
2 parents 759ae8a + 3f29fc1 commit cc1107d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
8 changes: 8 additions & 0 deletions .env-base
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,11 @@ ALLOW_INSECURE_REDIRECTS=false
#
TELEMETRY=true

#
# JN Mask
# Set a mask to enforce on the job number field in the admin.
# Format as: https://v15.vuetifyjs.com/en/components/text-fields#masks
#
JNMASK="######-##"


30 changes: 22 additions & 8 deletions app/api/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
const passport = require( 'passport' )
const adminCheck = require( './middleware/AdminCheck' )
const { exec } = require( 'child_process' )

module.exports = function ( app, express, urlRoot, plugins ) {

var r = new express.Router( )
let r = new express.Router( )

// strict auth will return a 401 if no authorization header is present. pass means req.user exists
let mandatoryAuthorisation = passport.authenticate( 'jwt-strict', { session: false } )
Expand Down Expand Up @@ -209,15 +210,28 @@ module.exports = function ( app, express, urlRoot, plugins ) {
if ( r.route.includes( 'objects' ) ) grouped.objects.push( r )
} )

let serverDescription = {
isSpeckleServer: true, // looks stupid, but is used for url validation by the clients
serverName: process.env.SERVER_NAME,
version: '1.x.x',
api: grouped,
plugins: plugins
let tagVersion = null
try {
exec( 'git describe --tags', ( err, stdout ) => {
tagVersion = stdout.split( '-' )[ 0 ].replace( /(\r\n|\n|\r)/gm, "" )
} )
} catch ( err ) {
// POKEMON
tagVersion = '1.x.x'
}

r.get( '/', ( req, res ) => res.json( serverDescription ) )
r.get( '/', ( req, res ) => {
let serverDescription = {
isSpeckleServer: true, // looks stupid, but is used for url validation by the clients
serverName: process.env.SERVER_NAME,
version: tagVersion || '1.x.x',
api: grouped,
plugins: plugins,
jnMask: process.env.JNMASK || "######-##"
}

return res.json( serverDescription )
} )

// mount all these routes up
app.use( urlRoot, r )
Expand Down

0 comments on commit cc1107d

Please sign in to comment.