Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Si Hyeong Lee writingdeveloper

🏠
Working from home
View GitHub Profile
@writingdeveloper
writingdeveloper / index.js
Created Feb 8, 2021
PowerShell Handling Node.js App
View index.js
const express = require('express');
const bodyParser = require("body-parser");
const path = require("path");
const Base64 = require('js-base64');
const {
exec
} = require('child_process');
const router = express.Router();
router.use(bodyParser.urlencoded({
@writingdeveloper
writingdeveloper / index.js
Last active Feb 5, 2021
Part of 'Windows Local User Management' code
View index.js
const express = require('express');
const bodyParser = require("body-parser");
const path = require("path");
const Base64 = require('js-base64');
// const Shell = require('node-powershell');
// var spawn = require("child_process").spawn,
// child;
const router = express.Router();
/* PowerShell Constructor */
View index.js
const express = require('express');
const bodyParser = require("body-parser");
const path = require("path");
const {
base64,
Base64
} = require('js-base64');
const {
Shell,
PSCommand
View Error-Handling-Patterns-Express.md

Handling Errors

Express.js makes it a breeze to handle errors in your routes.

Express lets you centralizes your error-handling through middleware.

Let's look at patterns for how to get the most out of your error-handling.

First, our error-handling middleware looks like this:

@writingdeveloper
writingdeveloper / clien.js
Created Mar 11, 2019
Puppeteer Auto Clien Screencapture App
View clien.js
const puppeteer = require('puppeteer');
let prevNumber;
function again() {
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
// Adjustments particular to this page to ensure we hit desktop breakpoint.
page.setViewport({
View init.coffee
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
View app.js
app.get('/topic', function(req,res){
res.send(req.query.id+' , '+req.query.name);
});
View temp.pug
html
head
title= title
body
h1 Hello Jade
ul
-for(var i=0; i<5; i++)
li coding
div= time
View app.js
var express = require('express');
var path = require('path');
var app = express();
app.locals.pretty = true;
app.set('view engine', 'pug');
app.set('views', path.join(__dirname, 'views'));
app.use(express.static(path.join(__dirname, 'public')));
app.get('/template', function(req, res) {
View app.js
var express = require('express');
var app = express();
var path = require('path');
app.use(express.static(path.join(__dirname, 'public')));
app.get('/', function(req, res) {
res.send('Hello home page');
});
app.get('/dynamic', function(req, res) {
var lis = '';