Skip to content

Commit d1ebf25

Browse files
committed
using std naming convention
1 parent 986825e commit d1ebf25

File tree

8 files changed

+72
-84
lines changed

8 files changed

+72
-84
lines changed

README-stg.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ get model URNs - as explained in the Setup/Usage Instructions.
4545
```
4646
* Replace the placeholders with your own keys in credentials.js, line #23 and #24 <br />
4747
```
48-
credentials.ConsumerKey =process.env.CONSUMERKEY || '<replace with your consumer key>';
48+
client_id: process.env.CONSUMERKEY || '<replace with your consumer key>';
4949

50-
credentials.ConsumerSecret =process.env.CONSUMERSECRET || '<replace with your consumer secret>';
50+
client_secret: process.env.CONSUMERSECRET || '<replace with your consumer secret>';
5151
```
5252
* In file credentials.js line #26, replace the BaseUrl address by the staging server address <br />
5353
```

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ get model URNs - as explained in the Setup/Usage Instructions.
3636
```
3737
* Replace the placeholders with your own keys in credentials.js, line #23 and #24 <br />
3838
```
39-
credentials.ConsumerKey =process.env.CONSUMERKEY || '<replace with your consumer key>';
39+
client_id: process.env.CONSUMERKEY || '<replace with your consumer key>';
4040

41-
credentials.ConsumerSecret =process.env.CONSUMERSECRET || '<replace with your consumer secret>';
41+
client_secret: process.env.CONSUMERSECRET || '<replace with your consumer secret>';
4242
```
4343
* Upload one of your models to your account and get its URN using another workflow sample, for example,
4444
- [this workflow sample in .Net WPF application](https://github.com/Developer-Autodesk/workflow-wpf-view.and.data.api) if you are using windows

credentials_.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,21 @@
1515
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
1616
// UNINTERRUPTED OR ERROR FREE.
1717
/////////////////////////////////////////////////////////////////////////////////
18+
var credentials ={
1819

19-
var credentials ={} ;
20+
credentials: {
21+
// Replace placeholder below by the Consumer Key and Consumer Secret you got from
22+
// http://developer.autodesk.com/ for the production server
23+
client_id: process.env.CONSUMERKEY || '<replace with your consumer key>',
24+
client_secret: process.env.CONSUMERSECRET || '<replace with your consumer secret>',
25+
grant_type: 'client_credentials'
26+
},
27+
28+
// If you which to use the Autodesk View & Data API on the staging server, change this url
29+
BaseUrl: 'https://developer.api.autodesk.com',
30+
Version: 'v1'
31+
} ;
2032

21-
// Replace placeholder below by the Consumer Key and Consumer Secret you got from
22-
// http://developer.autodesk.com/ for the production server
23-
credentials.ConsumerKey =process.env.CONSUMERKEY || '<replace with your consumer key>' ;
24-
credentials.ConsumerSecret =process.env.CONSUMERSECRET || '<replace with your consumer secret>' ;
25-
26-
// If you which to use the Autodesk View & Data API on the staging server, change this url
27-
credentials.BaseUrl = 'https://developer.api.autodesk.com' ;
33+
credentials.Authentication =credentials.BaseUrl + '/authentication/' + credentials.Version + '/authenticate'
2834

2935
module.exports =credentials ;

data/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!.gitignore

data/token.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

package.json

Lines changed: 32 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,33 @@
11
{
2-
"name": "AdnViewerBasic",
3-
"description": "A basic node.js server sample",
4-
"version": "1.0.0",
5-
"dependencies": {
6-
"serve-favicon": ">= 2.2.0",
7-
"express": ">= 4.12.3",
8-
"request": ">= 2.55.0",
9-
"body-parser": ">= 1.11.0",
10-
"formidable": ">= 1.0.17",
11-
"fs": ">= 0.0.2",
12-
"unirest": ">= 0.4.0",
13-
"async": ">= 0.9.0",
14-
"util": ">= 0.10.3",
15-
"path": ">=0.11.14"
16-
},
17-
"files": [
18-
"LICENSE",
19-
"README.md"
20-
],
21-
"engines": {
22-
"node": ">= 0.10.0"
23-
},
24-
"contributors": [
25-
"Philippe Leefsma <[email protected]>"
26-
],
27-
"license": "MIT",
28-
"scripts": {
29-
"start": "node server.js"
30-
},
31-
"repository": {
32-
"type": "git",
33-
"url": "https://github.com/Developer-Autodesk/workflow-node.js-view.and.data.api.git"
34-
}
35-
}
36-
}
2+
"name": "AdnViewerBasic",
3+
"description": "A basic node.js server sample",
4+
"version": "1.0.0",
5+
"dependencies": {
6+
"serve-favicon": ">= 2.2.0",
7+
"express": ">= 4.12.3",
8+
"request": ">= 2.55.0",
9+
"body-parser": ">= 1.11.0",
10+
"formidable": ">= 1.0.17",
11+
"unirest": ">= 0.4.0",
12+
"async": ">= 0.9.0"
13+
},
14+
"files": [
15+
"LICENSE",
16+
"README.md"
17+
],
18+
"engines": {
19+
"node": ">= 0.10.0"
20+
},
21+
"contributors": [
22+
"Philippe Leefsma <[email protected]>",
23+
"Cyrille Fauvel <[email protected]>"
24+
],
25+
"license": "MIT",
26+
"scripts": {
27+
"start": "node server.js"
28+
},
29+
"repository": {
30+
"type": "git",
31+
"url": "https://github.com/Developer-Autodesk/workflow-node.js-view.and.data.api.git"
32+
}
33+
}

routes/api.js

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,37 +15,25 @@
1515
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
1616
// UNINTERRUPTED OR ERROR FREE.
1717
/////////////////////////////////////////////////////////////////////////////////
18-
var fs = require('fs');
19-
var credentials ;
20-
if ( !fs.existsSync ('credentials.js') ) {
21-
console.log ('No credentials.js file present, assuming using CONSUMERKEY & CONSUMERSECRET system variables.') ;
22-
credentials =require('../credentials_') ;
23-
} else {
24-
credentials =require('../credentials') ;
25-
}
26-
var express = require('express');
27-
var request = require('request');
18+
var credentials =(require ('fs').existsSync ('credentials.js') ?
19+
require('../credentials')
20+
: (console.log ('No credentials.js file present, assuming using CONSUMERKEY & CONSUMERSECRET system variables.'), require('../credentials_'))) ;
21+
var express =require ('express') ;
22+
var request =require ('request') ;
2823

29-
var router = express.Router();
24+
var router =express.Router () ;
3025

3126
///////////////////////////////////////////////////////////////////////////////
3227
// Generates access token
3328
///////////////////////////////////////////////////////////////////////////////
34-
router.get('/token', function (req, res) {
35-
var params = {
36-
client_id: credentials.ConsumerKey,
37-
client_secret: credentials.ConsumerSecret,
38-
grant_type: 'client_credentials'
39-
} ;
40-
41-
request.post(
42-
credentials.BaseUrl + '/authentication/v1/authenticate',
43-
{ form: params },
29+
router.get ('/token', function (req, res) {
30+
request.post (
31+
credentials.Authentication,
32+
{ form: credentials.credentials },
4433
function (error, response, body) {
45-
if (!error && response.statusCode == 200) {
46-
res.send(body);
47-
}
48-
});
49-
});
34+
if ( !error && response.statusCode == 200 )
35+
res.send (body) ;
36+
}) ;
37+
}) ;
5038

51-
module.exports = router;
39+
module.exports =router ;

routes/lmv.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
1919
// UNINTERRUPTED OR ERROR FREE.
2020
//
21+
var credentials =(require ('fs').existsSync ('credentials.js') ?
22+
require('../credentials')
23+
: (console.log ('No credentials.js file present, assuming using CONSUMERKEY & CONSUMERSECRET system variables.'), require('../credentials_'))) ;
2124
var express =require ('express') ;
2225
var request =require ('request') ;
2326
// unirest (http://unirest.io/) or SuperAgent (http://visionmedia.github.io/superagent/)
@@ -26,7 +29,6 @@ var events =require('events') ;
2629
var util =require ('util') ;
2730
var path =require ('path') ;
2831
var fs =require ('fs') ;
29-
var credentials =require ('../credentials') ;
3032

3133
// LMV object
3234
function Lmv (bucketName) {
@@ -51,16 +53,10 @@ util.inherits (Lmv, events.EventEmitter) ;
5153
// POST /authentication/v1/authenticate
5254
/*static*/ Lmv.refreshToken =function () {
5355
console.log ('Refreshing Autodesk Service token') ;
54-
var params ={
55-
client_id: credentials.ClientId,
56-
client_secret: credentials.ClientSecret,
57-
grant_type: 'client_credentials'
58-
} ;
59-
var endpoint =credentials.BaseUrl + '/authentication/v1/authenticate' ;
60-
unirest.post (endpoint)
56+
unirest.post (credentials.Authentication)
6157
.header ('Accept', 'application/json')
6258
.type ('application/x-www-form-urlencoded')
63-
.send (params)
59+
.send (credentials.credentials)
6460
.end (function (response) {
6561
try {
6662
if ( response.statusCode != 200 )

0 commit comments

Comments
 (0)