Skip to content

Commit

Permalink
Merge pull request #1 from kaminchu/feature/to_modern
Browse files Browse the repository at this point in the history
ナウでヤングな感じにした
  • Loading branch information
kaminchu authored Jun 4, 2018
2 parents bc21ff6 + 25607d2 commit 98cff26
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 29 deletions.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["es2015"]
}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.vscode
node_modules
node_modules
dist
24 changes: 0 additions & 24 deletions app.js

This file was deleted.

8 changes: 8 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
var gulp = require('gulp');
var babel = require('gulp-babel');

gulp.task('default', function () {
return gulp.src(['src/*.js', 'src/**/*.js'])
.pipe(babel())
.pipe(gulp.dest('dist'));
});
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node ./app.js"
"build": "gulp",
"start": "node ./dist/app.js"
},
"dependencies": {
"http": "*",
"url": "*"
"devDependencies": {
"babel-core": "^6.26.3",
"babel-preset-es2015": "^6.24.1",
"gulp": "^3.9.1",
"gulp-babel": "^7.0.1"
}
}
33 changes: 33 additions & 0 deletions src/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import http from "http";
import url from "url";

const PORT = process.env.PORT || 3000;

const parseToButimili = (req) => {
const pathname = url.parse(req.url).pathname.substring(1);
const users = pathname
.split(new RegExp("[\/+]"))
.map(e => e.indexOf("@") == 0 ? e : "@" + e)
.join(' ');

const butimili = `${users} うおおおおおおあああああああああああああああああああ!!!!!!!!!!! (ブリブリブリブリュリュリュリュリュリュ!!!!!!ブツチチブブブチチチチブリリイリブブブブゥゥゥゥッッッ!!!!!!!)`;
const toSubstring = butimili.substr(0, 139);
return encodeURI(toSubstring);
};

const app = (req, res) => {
const butimili_text = parseToButimili(req);
const butimili_url = `https://twitter.com/intent/tweet?text=${butimili_text}`;

res.writeHead(302, { 'Location': butimili_url });
res.end();
};

// server
const server = http.createServer(app);
server.listen(PORT);
server.listen(PORT, function onListen() {
const address = server.address();
console.log('Listening on: %j', address);
console.log(' -> that probably means: http://localhost:%d', address.port);
});

0 comments on commit 98cff26

Please sign in to comment.