forked from Sunbird-RC/sunbird-rc-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cf8cab3
commit b679e78
Showing
9 changed files
with
71 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,33 @@ | ||
const axios = require('axios'); | ||
let token = ''; | ||
let osids = [""]; | ||
osids.forEach(osid => { | ||
|
||
|
||
let config = { | ||
method: 'get', | ||
maxBodyLength: Infinity, | ||
url: 'http://localhost:8081/api/v1/ProofOfAchievement/'+osid, | ||
headers: { | ||
'Content-Type': 'application/json', | ||
'Authorization': 'Bearer ' + token, | ||
const certificateController = require("./src/routes/certificate_controller"); | ||
const http = require('http'); | ||
const port = process.env.PORT || 4321; | ||
|
||
const server = http.createServer(async (req, res) => { | ||
const label = `${req.url}-${new Date().getTime()}`; | ||
console.time(label) | ||
console.log(`API ${req.method} ${req.url} called`); | ||
try { | ||
if (req.method === 'GET' && req.url.startsWith("/health")) { | ||
res.end("OK") | ||
} else if (req.method === 'POST' && req.url.startsWith("/api/v1/certificate") && ["application/pdf"].includes(req.headers.accept)) { | ||
const data = await certificateController.getCertificatePDF(req, res); | ||
res.end(data) | ||
} else if (req.method === 'POST' && req.url.startsWith("/api/v1/certificate") && ["text/html", "image/svg+xml"].includes(req.headers.accept)) { | ||
const data = await certificateController.getCertificate(req, res); | ||
res.end(data) | ||
} else { | ||
res.statusCode = 404; | ||
res.end("Not found"); | ||
} | ||
}; | ||
|
||
axios.request(config) | ||
.then((response) => { | ||
const getResp = response.data; | ||
delete getResp["osUpdatedAt"] | ||
delete getResp["osUpdatedBy"] | ||
delete getResp["_osSignedData"] | ||
delete getResp["osOwner"] | ||
delete getResp["osCreatedAt"] | ||
delete getResp["osCreatedBy"] | ||
getResp["achievementTitle"] = "Participation" | ||
console.log(getResp) | ||
let config = { | ||
method: 'put', | ||
maxBodyLength: Infinity, | ||
url: 'http://localhost:8081/api/v1/ProofOfAchievement/' + getResp["osid"], | ||
headers: { | ||
'Content-Type': 'application/json', | ||
'Authorization': 'Bearer ' + token, | ||
}, | ||
data : getResp | ||
}; | ||
|
||
axios.request(config) | ||
.then((response) => { | ||
console.log(JSON.stringify(response.data)); | ||
}) | ||
.catch((error) => { | ||
console.log(error); | ||
}); | ||
|
||
|
||
}) | ||
.catch((error) => { | ||
console.log(error); | ||
}); | ||
}) | ||
|
||
|
||
|
||
} finally { | ||
if (!res.writableEnded) { | ||
res.statusCode = 500; | ||
res.end("Error occurred"); | ||
} | ||
} | ||
console.timeEnd(label) | ||
}); | ||
|
||
server.listen(port, async () => { | ||
console.log(`Server listening on port ${port}`); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
RELEASE_VERSION=latest | ||
DB_DIR=db-data-3 | ||
SEARCH_PROVIDER_NAME=dev.sunbirdrc.registry.service.NativeSearchService | ||
FUSION_WRAPPER_BUILD=services/sample-fusionauth-service/ | ||
FUSIONAUTH_ISSUER_URL=http://fusionauth:9011/ | ||
oauth2_resource_uri=http://fusionauth:9011/ | ||
oauth2_resource_roles_path=roles | ||
identity_provider=dev.sunbirdrc.auth.genericiam.AuthProviderImpl | ||
sunbird_sso_url=http://fusionauthwrapper:3990/fusionauth/api/v1/user | ||
IMPORTS_DIR=services/sample-fusionauth-service/imports |