more env files

master
Juan 3 years ago
parent 330e2176a6
commit 65c81de4ef

@ -2,6 +2,18 @@
header("Content-type: text/plain;charset=utf-8"); header("Content-type: text/plain;charset=utf-8");
// curl :
// https://www.php.net/manual/fr/intro.curl.php
// curl basics
// https://weichie.com/blog/curl-api-calls-with-php/
// curl basics with auth
// https://weichie.com/blog/php-curl-api-calls-authentication/
// curl en fr
// https://analyse-innovation-solution.fr/publication/fr/php/curl-post-get-proxy-https
// guide du dévbutant
// https://rapidapi.com/blog/how-to-use-an-api-with-php/
// vars // vars
$api_key = "bc1e13327f7f4876902d4bc45c30e102"; $api_key = "bc1e13327f7f4876902d4bc45c30e102";
$api_url = "https://api.geoapify.com/v1/"; $api_url = "https://api.geoapify.com/v1/";

@ -2,8 +2,6 @@
//from : https://api.wordpress.org/secret-key/1.1/salt //from : https://api.wordpress.org/secret-key/1.1/salt
define('AUTH_KEY', '2(QMu)jt|2!(9t]V!4SB/y,+T]LcvGZ8-sV@vS6RUgR!_]&S}{6/RZjAmLeW28On'); define('AUTH_KEY', '2(QMu)jt|2!(9t]V!4SB/y,+T]LcvGZ8-sV@vS6RUgR!_]&S}{6/RZjAmLeW28On');
function get_client_ip() function get_client_ip()
{ {
$ip = null; $ip = null;

@ -0,0 +1,13 @@
# port du server node au démarrage
SERVER_PORT=4444
# informations de connexion à la base de donnée ...
# le server
DB_HOST=127.0.0.1
# le port
DB_PORT=3306
# user et password
DB_USR=test
DB_PWD=averylongpassword
# nom de la base
DB_NAME=thedatabasename

@ -10,10 +10,17 @@ var util = require('util');
// si on veut reste on "write" // si on veut reste on "write"
var logfile = fs.createWriteStream(process.cwd() + '/server.log', { flags: 'w' }); var logfile = fs.createWriteStream(process.cwd() + '/server.log', { flags: 'w' });
console.log = function () { console.log = function () {
logfile.write(util.format.apply(null, arguments) + '\n'); let args = Array.from(arguments);
args = args.map(function (value) {
datetime=new Date();
value="\n"+datetime.toLocaleString('fr-FR', {hour12: false}) + " - " + typeof(value) + " - " +value.toString();
return(value);
});
logfile.write(args.join(''));
process.stdout.write(util.format.apply(null, arguments) + '\n'); process.stdout.write(util.format.apply(null, arguments) + '\n');
} }
const server = http.createServer(function (request, response) { const server = http.createServer(function (request, response) {
parsedUrl = url.parse(request.url, false); parsedUrl = url.parse(request.url, false);
json_response(200,{status : "active"},response); json_response(200,{status : "active"},response);
@ -41,7 +48,7 @@ fs.access(local_env_file, fs.constants.R_OK, (err) => {
server.listen(process.env.SERVER_PORT || 8080); server.listen(process.env.SERVER_PORT || 8080);
datetime=new Date(); datetime=new Date();
console.log('server started at :'+datetime.toLocaleString('fr-FR', {hour12: false})); console.log('server started at :'+datetime.toLocaleString('fr-FR', {hour12: false}));
console.log('server started at :'+datetime.toLocaleString('en-EN'),'server started at :'+datetime); console.log("coucou",1,'server started at :'+datetime.toLocaleString('en-EN'),'server started at :'+datetime);
}); });
//usefull functions //usefull functions

@ -1,9 +1,17 @@
const http = require('http'); const http = require('http');
const url = require('url'); const url = require('url');
const fs = require('fs');
var config=null;
//if config.local.jsoon exists load it
if(fs.existsSync(process.cwd() + '/config.local.json')){
config = require(process.cwd() + '/config.local.json');
}
// else load normal config file
else {
config = require(process.cwd() + '/config.json');
}
// load config file
const config = require(process.cwd() + '/config.json');
function outputHTML5(status, response, content, title) function outputHTML5(status, response, content, title)
{ {
response.writeHead(status, { 'Content-Type': 'text/html; charset=utf-8' }); response.writeHead(status, { 'Content-Type': 'text/html; charset=utf-8' });
@ -25,12 +33,13 @@ function outputHTML5(status, response, content, title)
response.end(); response.end();
} }
//par defaut on se considère
let env = 'install';
var server = http.createServer(function (request, response) { var server = http.createServer(function (request, response) {
if(request.url === "/") { if(request.url === "/") {
startup_args = process.argv.slice(2);
content = config.staging.config_id; content = config[startup_args[0]].config_id;
outputHTML5(200,response,content,"Server info");
outputHTML5(200,response,content,"Server info");
} }
else { else {
outputHTML5(404,response,'Y\'a rien ici',"Oups"); outputHTML5(404,response,'Y\'a rien ici',"Oups");

Loading…
Cancel
Save