[Snippets] Improve ts
This commit is contained in:
@@ -1,43 +1,28 @@
|
||||
{
|
||||
"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",
|
||||
"prefix": "setupExpressApp",
|
||||
"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} );",
|
||||
"import express from 'express';",
|
||||
"import path from 'path';",
|
||||
"import expressSession from 'express-session';",
|
||||
"import fs from 'fs';\n",
|
||||
"let app = express();",
|
||||
"\napp.use( expressSession ( {\n\tsecret: $1,\n\tresave: true,\n\tsaveUninitialized: false\n} ) );",
|
||||
"\n\napp.get( '/', ( request, response ) => {\n$4\n} );",
|
||||
"app.use( ( _request: express.Request, response: express.Response ) => {",
|
||||
"\tresponse.sendFile( path.join( __dirname, '$3' ) ) \n} );",
|
||||
"\n\nconst PORT = process.env.PORT || 8080;",
|
||||
"http.createServer( app ).listen( PORT );"
|
||||
"app.listen( PORT );"
|
||||
]
|
||||
},
|
||||
"ExpressJS-Route": {
|
||||
"prefix": "jsEjsRoute",
|
||||
"prefix": "expressRoute",
|
||||
"body": "\n\napp.get( '$1', ( request: express.Request, response: express.Response ) => {\n$4\n} );"
|
||||
},
|
||||
"JSAsync": {
|
||||
"prefix": "jsAsync",
|
||||
"prefix": "async-sync",
|
||||
"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": [
|
||||
|
||||
@@ -9,13 +9,9 @@
|
||||
"description": "Setup the basic structure of a class in JS"
|
||||
},
|
||||
"JSAsync": {
|
||||
"prefix": "jsAsync",
|
||||
"prefix": "async-sync",
|
||||
"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": [
|
||||
|
||||
Reference in New Issue
Block a user