This file contains hidden or 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
| version: '3' | |
| services: | |
| app: | |
| build: | |
| context: . | |
| dockerfile: ./node/Dockerfile | |
| container_name: node_app | |
| ports: | |
| - '3000:3000' |
This file contains hidden or 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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title><%= title %></title> | |
| <link rel="stylesheet" href="/stylesheets/style.css" /> | |
| <script src="https://apis.google.com/js/platform.js" async defer></script> | |
| <meta name="google-signin-client_id" content="<%= clientIdUrl %>" /> | |
| <script> | |
| // called by google client | |
| function onSignIn(googleUser) { |
This file contains hidden or 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
| <script src="https://apis.google.com/js/platform.js" async defer></script> | |
| <meta name="google-signin-client_id" content="<%= clientIdUrl %>" /> |
This file contains hidden or 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
| <script> | |
| // called by google client | |
| function onSignIn(googleUser) { | |
| var id_token = googleUser.getAuthResponse().id_token; | |
| // never log these out on a real app | |
| console.log('id_token: ', id_token); | |
| var profile = googleUser.getBasicProfile(); | |
| console.log('ID: ' + profile.getId()); | |
| console.log('Name: ' + profile.getName()); | |
| console.log('Image URL: ' + profile.getImageUrl()); |
This file contains hidden or 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
| import { OAuth2Client } from 'google-auth-library'; | |
| const p = console.log; | |
| /** | |
| * this establishes the connection | |
| * @return { OAuth2Client } | |
| */ | |
| function getOAuth2Client() { | |
| return new OAuth2Client('YOUR_CLIENT_ID', 'YOUR_CLIENT_SECRET', 'REDIRECT_URL'); | |
| } |
This file contains hidden or 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
| import { OAuth2Client } from 'google-auth-library'; | |
| const p = console.log; | |
| /** APIs Explorer for OAuth2 v1: https://developers.google.com/apis-explorer/#p/oauth2/v1/ **/ | |
| const infoUrl = 'https://www.googleapis.com/oauth2/v1/userinfo?alt=JSON'; | |
| /** | |
| * information scope needed | |
| * reference: https://developers.google.com/identity/protocols/googlescopes | |
| * check: Google OAuth2 API, v2 | |
| */ |
This file contains hidden or 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
| /** | |
| * get selected fields of userinfo | |
| * @param { string } code | |
| * @return { object } | |
| */ | |
| async function getUserInfoFromCode(code) { | |
| const client = getOAuth2Client(); | |
| const data = await client.getToken(code); | |
| client.setCredentials(data.tokens); | |
| const userinfo = await client.request({ url: infoUrl }); |
This file contains hidden or 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
| /** | |
| * Mocha Test Template | |
| * refs ================================ | |
| * Mocha: https://mochajs.org | |
| * Chai: https://www.chaijs.com | |
| * Chai-As-Promised: https://www.chaijs.com/plugins/chai-as-promised/ | |
| * Sinon: https://sinonjs.org | |
| * debug: https://www.npmjs.com/package/debug | |
| */ | |
| import chai from 'chai'; |
This file contains hidden or 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
| /** | |
| * wrapper for Validator.js | |
| * ref: | |
| * https://www.npmjs.com/package/validator | |
| */ | |
| import validator from 'validator'; | |
| /** | |
| * error messages | |
| */ |
This file contains hidden or 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
| import AWS from 'aws-sdk'; | |
| import { | |
| DocumentClient, | |
| PutItemInput, | |
| PutItemOutput, | |
| GetItemInput, | |
| QueryInput, | |
| ScanInput, | |
| DeleteItemInput, | |
| DeleteItemOutput, |