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
-- The architecture: | |
-- a hidden schema that contains sensitive info | |
-- a public schema exposed by postgrest (https://github.com/begriffs/postgrest) | |
-- the problem: you can't populate env vars with psql within plpgsql functions | |
-- I wanted to have my jwt_secret not in clear in the code | |
-- so that I can switch environments and not expose this token on github | |
-- step 1: create a enum type in the hidden schema containing only your variable | |
create type hidden.jwt_secret as enum (:jwt_secret); |
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
firstname | name | pseudo | avatar_url | password | external_id | role | chat_enabled | website | max_chat | location | conversation_number | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
import1 | import1 | import1@gmail.com | tarass | https://yt3.ggpht.com/-z5BZ8hRtQ8U/AAAAAAAAAAI/AAAAAAAAAAA/PQpARaPvj-Q/s88-c-k-no-mo-rj-c0xffffff/photo.jpg | tamertamer | 1 | admin | 1 | 1 | 4 | World | 0 |
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
app.get('/seed', function (req, res) { | |
if (req.headers['x-mentorleo-token'] != 'MENTORLEO') { | |
res.send('NOK'); | |
} else { | |
// DO STUFF | |
res.send('OK'); | |
} | |
}); |
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
const config = { | |
dbURI: process.env.MONGODB_ADDON_URI ? process.env.MONGODB_ADDON_URI : 'mongodb://localhost:27017' | |
}; |
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
const assert = require('assert'); // Lib already available with Node.js, no need to install anything with npm | |
const express = require('express'); | |
const MongoClient = require('mongodb').MongoClient; | |
const config = { | |
dbURI: 'mongodb://localhost:27017/test' | |
}; | |
const app = express(); |
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
fs.readFileAsync("file.json").then(JSON.parse).then(function (val) { | |
console.log(val.success); | |
}) | |
.catch(SyntaxError, function (e) { | |
console.error("invalid json in file"); | |
}) | |
.catch(function (e) { | |
console.error("unable to read file"); | |
}); |
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
fs.readFile("file.json", function (err, val) { | |
if (err) { | |
console.error("unable to read file"); | |
} | |
else { | |
try { | |
val = JSON.parse(val); | |
console.log(val.success); | |
} | |
catch (e) { |
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
var express = require('express'); | |
var app = express(); | |
app.get('/hello', function (req, res) { | |
res.send('Hello World!'); | |
}); | |
app.listen(8080, function () { | |
console.log('Example app listening on port 8080!'); | |
}); |
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
var mentor = '@damien'; | |
console.log('My Mentor for this mentorleo.co project is ' + mentor); |
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
module.exports = React.createClass({ | |
// The state is an object with keys that represents the text of the labels | |
// And value is the activation / disabled | |
// | |
// From var obj = {mentor: 'Léo', week2: 'Day5'} | |
// We can get the array of the keys by using Object.keys(obj) | |
// This should give ['mentor', 'week2'] | |
getInitialState() { | |
return { | |
skills: { |
NewerOlder