Skip to content

Instantly share code, notes, and snippets.

View RyanKor's full-sized avatar
🎯
Focusing

SeungTaeKim RyanKor

🎯
Focusing
View GitHub Profile
@RyanKor
RyanKor / SeungTaeKim's GitHub Stats
Last active September 24, 2021 12:06
SeungTaeKim's GitHub Stats
⭐ Total Stars: 13
➕ Total Commits: 847
🔀 Total PRs: 215
🚩 Total Issues: 296
📦 Contributed to: 3
@RyanKor
RyanKor / I'm a night 🦉
Last active September 25, 2021 00:12
I'm a night 🦉
🌞 Morning 49 commits ██▎░░░░░░░░░░░░░░░░░░ 10.7%
🌆 Daytime 110 commits █████░░░░░░░░░░░░░░░░ 24.1%
🌃 Evening 180 commits ████████▎░░░░░░░░░░░░ 39.4%
🌙 Night 118 commits █████▍░░░░░░░░░░░░░░░ 25.8%
@RyanKor
RyanKor / post.js
Created October 24, 2020 18:52
router/post.js
const express = require("express");
const router = express.Router();
const postController = require("../controllers/post");
router.post("/", postController.textUpload);
router.get("/hashtag", postController.hashtagSearch);
@RyanKor
RyanKor / main.pug
Created October 24, 2020 18:50
Main page for hash tag
extends layout
block content
if user
.twits
form#hashtag-form(action='/post/hashtag')
input(type='text' name='hashtag' placeholder='Tag Search')
button.btn Search
form#sns-form(action='/post' method='POST' enctype='multipart/form-data')
.sns-discription post content
@RyanKor
RyanKor / post.js
Last active October 24, 2020 18:40
Hash Tag Controller/post.js
const { Post, Hashtag } = require("../models");
exports.textUpload = async (req, res, next) => {
try {
const post = await Post.create({
content: req.body.content,
img: req.body.url,
userId: req.user.id,
});
const hashtags = req.body.content.match(/#[^\s#]*/g);
@RyanKor
RyanKor / post.js
Created October 24, 2020 18:34
post.js setting
module.exports = (sequelize, DataTypes) =>
(sequelize.define(
"post",
{
content: {
type: DataTypes.STRING(140),
allowNull: false,
},
img: {
type: DataTypes.STRING(200),
@RyanKor
RyanKor / hashtag.js
Created October 24, 2020 18:33
Hashtag.js setting
module.exports = (sequelize, DataTypes) =>
sequelize.define(
"hashtag",
{
title: {
type: DataTypes.STRING(15),
allowNull: false,
unique: true,
},
},
@RyanKor
RyanKor / index.js
Last active October 24, 2020 18:30
Hash setting - models/index.js
const Sequelize = require("sequelize");
const env = process.env.NODE_ENV || "development";
const config = require("../config/config.json")[env];
const db = {};
const sequelize = new Sequelize(
config.database,
config.username,
config.password,
config
@RyanKor
RyanKor / config.json
Created October 24, 2020 18:20
MySQL Config.json
{
"development": {
"username": "username",
"password": "password",
"database": "sns",
"host": "127.0.0.1",
"dialect": "mysql"
},
}
@RyanKor
RyanKor / app.js
Created October 24, 2020 18:12
Hash Tag 기능 구현을 위한 app.js 세팅
const path = require("path");
const express = require("express");
const bodyParser = require("body-parser");
const cookieParser = require("cookie-parser");
const morgan = require("morgan");
const flash = require("connect-flash"); // req.flash() requires sessions
require("dotenv").config();
const { sequelize } = require("./models"); // ./models === ./passport/(index.js)