Skip to content

Instantly share code, notes, and snippets.

app.post(`/api/:userId/posts`, async (req, res) => {
const token = await tokenService.getToken(req);
const response = await api.post(`http://internal.corp.com/${req.params.userId}/posts?message=${req.query.message}&token=${token}`);
return res.send(response.data);
});
@jaydenlin
jaydenlin / getCheckedKeys.js
Created December 8, 2020 19:01
getCheckedKeys.js
const parseTagId = (key) => {
//取 tag_588 中的 tag id 數字
return key.match(/\d+/g) === null ? null: key.match(/\d+/g)[0];
}
const isTagKey = (key) => {
//判斷是不是 tag (資料夾會是undefined) 以及是否可以取 tag id
return typeof key !== "undefined" && parseTagId(key) !== null;
}
@jaydenlin
jaydenlin / next.config.js
Created November 1, 2018 01:46
next.config.js
const withCSS = require('@zeit/next-css')
const path = require('path')
// module.exports = withCSS({
// cssModules: true
// })
const avoidPaths = ['node_modules/@shopify/polaris/', 'node_modules/rc-steps/assets/', 'node_modules/react-table/', 'node_modules/react-toastify/dist/', 'node_modules/react-id-swiper/src/styles/css/swiper.css'].map(d => path.join(__dirname, d));
function canBeTransformed(pathToCheck) {
return !avoidPaths.some(function(v) {
const path = pathToCheck.substr(0, pathToCheck.lastIndexOf('/') + 1);
@jaydenlin
jaydenlin / Triple Cookie Submit.html
Last active May 5, 2018 09:51
Triple Cookie Submit.html
@jaydenlin
jaydenlin / Triple Cookie Submit.java
Last active May 5, 2018 09:52
Triple Cookie Submit.java
@jaydenlin
jaydenlin / Double Cookie Submit.html
Created May 4, 2018 17:44
Double Cookie Submit.html
@jaydenlin
jaydenlin / Double Cookie Submit.java
Last active May 4, 2018 17:43
Double Cookie Submit.java
@jaydenlin
jaydenlin / CSRF POST ajax.js
Created May 4, 2018 14:36
CSRF POST ajax.js
$(function () {
var token = $("meta[name='_csrf']").attr("content");
var header = $("meta[name='_csrf_header']").attr("content");
$(document).ajaxSend(function(e, xhr, options) {
xhr.setRequestHeader(header, token);
});
});
@jaydenlin
jaydenlin / CSRF POST ajax.html
Last active May 4, 2018 14:36
CSRF POST ajax.html
<html>
<head>
<meta name="_csrf" content="XXDDHHIIUUUEEEEJJAAA"/>
<meta name="_csrf_header" content="X-CSRF-TOKEN"/>
<!-- ... -->
</head>
<!-- ... -->
<form method='POST' action='/buy.php'>
<input type='text' name='item'>
<input type='hidden' name='csrf-token' value='XXDDHHIIUUUEEEEJJAAA'>
<input type='submit' value='submit'>
</form>