{ "JS-Class": { "prefix": "jsSetupClass", "body": "class $1 { \n\tconstructor () {} \n\n \t$2 () {\n\t$3\n\t}\n}", "description": "Setup the basic structure of a class in JS" }, "ExpressJS": { "prefix": "jsExpressSetup", "body": [ "const express = require( 'express' );", "let app = express();", "const path = require( 'path' );", "const expressSession = require( 'express-session' );", "const fs = require( 'fs' );", "const bodyParser = require( 'body-parser' );", "const cookieParser = require( 'cookie-parser' )", "const favicon = require( 'serve-favicon' );", "\napp.use( expressSession ( {\n\tsecret: $1,\n\tresave: true,\n\tsaveUninitialized: true\n} ) );", "app.use( bodyParser.urlencoded( { extended: false } ) );", "app.use( bodyParser.json() );", "app.use( cookieParser() );", "app.use( favicon( path.join( __dirname + '$2' ) ) );\n", "app.use( ( request, response, next ) => {\n\tresponse.sendFile( path.join( __dirname + '$3' ) ) \n} );", "\n\napp.get( '/', ( request, response ) => {\n$4\n} );", "\n\nconst PORT = process.env.PORT || 8080;", "http.createServer( app ).listen( PORT );" ] }, "ExpressJS-Route": { "prefix": "jsEjsRoute", "body": "\n\napp.get( '$1', ( request, response ) => {\n$4\n} );" }, "JSAsync": { "prefix": "jsAsync", "body": "(async () => {\n$1\n} ) ();" }, "JSpromiseReturnFunc": { "prefix": "jsPromise", "body": "function $1 () {\n\treturn new Promise( ( resolve, reject ) => {\n\t$2\n\t} );\n}" }, "fetch from other url": { "prefix": "remoteURL", "body": [ "localStorage.getItem( 'url' ) + '/$1'" ], "description": "remote URL fetching (get from base address from local storage)" }, "fetch post": { "prefix": "fetchPost", "body": [ "const fetchOptions = {", "\tmethod: 'post',", "\tbody: JSON.stringify( $1 ),", "\tcredentials: 'include',", "\theaders: {", "\t\t'Content-Type': 'application/json',", "\t\t'charset': 'utf-8'", "\t}", "};", "fetch( $2, fetchOptions ).then( res => {", "\tif ( res.status === 200 ) {", "\t\tres.json().then( json => {", "\t\t\t$3", "\t\t} );", "\t}", "} );", "$4" ], "description": "POST request using fetch" }, "fetch get": { "prefix": "fetchGet", "body": [ "fetch( $2, { credentials: 'include' } ).then( res => {", "\tif ( res.status === 200 ) {", "\t\tres.json().then( json => {", "\t\t\t$3", "\t\t} );", "\t}", "} );", "$4" ], "description": "POST request using fetch" }, "promise": { "prefix": "promise", "body": [ "return new Promise( ( resolve, reject ) => {", "\t", "} );" ] } }