Skip to content

Commit 18f627c

Browse files
committed
Prepare guide for development environment
1 parent 570346c commit 18f627c

File tree

10 files changed

+100
-18
lines changed

10 files changed

+100
-18
lines changed

.env.development

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ PORT=5000
22

33
TYPEORM_CONNECTION=postgres
44
TYPEORM_HOST=localhost
5-
TYPEORM_USERNAME=velognext
6-
TYPEORM_PASSWORD=velognext
7-
TYPEORM_DATABASE=velognext
5+
TYPEORM_USERNAME=velog
6+
TYPEORM_PASSWORD=velogpw
7+
TYPEORM_DATABASE=velog
88
TYPEORM_PORT=5432
99
TYPEORM_SYNCHRONIZE=false
1010
TYPEORM_LOGGING=true
@@ -21,4 +21,6 @@ FACEBOOK_ID=686892251796798
2121
FACEBOOK_SECRET=339f16ee1f3d011e927410193ed594ec
2222
GOOGLE_ID=997152497044-0kq4paur2i6rq9aibjp5jjlapc32eek2.apps.googleusercontent.com
2323
GOOGLE_SECRET=26ZmeLM5aRx4VPPF88j8UieP
24-
HASH_KEY=SampleHashKey
24+
HASH_KEY=SampleHashKey
25+
API_HOST=localhost:5000
26+
CLIENT_HOST=localhost:3000

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# velog-server
2+
3+
Velog is a blog platform for developers. It provides markdown editor with syntax highlighter enabled. Currently, this service only supports Korean language.
4+
5+
Website link: https://velog.io/
6+
7+
Frontend project of service is at another Repo - [velog-client](https://github.com/velopert/velog-server)
8+
9+
## Project Stack
10+
- Node.js
11+
- TypeScript
12+
- Apollo GraphQL
13+
- PostgreSQL
14+
- TypeORM
15+
- Redis
16+
- ElasticSearch
17+
- Koa
18+
- Serverless
19+
- AWS
20+
- Lambda
21+
- SES
22+
- API Gateway
23+
- S3
24+
- Cloudfront
25+
26+
## Running on your machine
27+
28+
[Link](https://github.com/velopert/velog-server/wiki/Running-on-your-machine)

docker/postgresql/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
docker

docker/postgresql/docker-compose.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
version: '3.1'
2+
3+
services:
4+
5+
db:
6+
container_name: postgres
7+
image: postgres
8+
restart: always
9+
environment:
10+
POSTGRES_PASSWORD: postgrespw
11+
ports:
12+
- "5432:5432"
13+
command: postgres -c max_connections=1000
14+
volumes:
15+
- ./docker/data:/var/lib/postgresql/data
16+
- ./../../init.sql:/docker-entrypoint-initdb.d/init.sql

docker/redis/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
FROM bitnami/redis:5.0
2+
ENV ALLOW_EMPTY_PASSWORD=yes

docker/redis/docker-compose.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
version: '2'
2+
3+
services:
4+
redis:
5+
image: 'bitnami/redis:5.0'
6+
environment:
7+
# ALLOW_EMPTY_PASSWORD is recommended only for development.
8+
- ALLOW_EMPTY_PASSWORD=yes
9+
ports:
10+
- '6379:6379'
11+
volumes:
12+
- 'redis_data:/bitnami/redis/data'
13+
14+
volumes:
15+
redis_data:
16+
driver: local

schema.sql renamed to init.sql

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
CREATE DATABASE velog
2+
LC_COLLATE 'C'
3+
LC_CTYPE 'C'
4+
ENCODING 'UTF8'
5+
TEMPLATE template0;
6+
7+
CREATE USER velog WITH ENCRYPTED PASSWORD 'velogpw';
8+
GRANT ALL PRIVILEGES ON DATABASE velog to velog;
9+
10+
\c velog
11+
112
--
213
-- PostgreSQL database dump
314
--
@@ -1190,13 +1201,6 @@ CREATE INDEX users_email ON public.users USING btree (email);
11901201
CREATE INDEX users_username ON public.users USING btree (username);
11911202

11921203

1193-
--
1194-
-- Name: posts tsvectorupdate; Type: TRIGGER; Schema: public; Owner: velog
1195-
--
1196-
1197-
CREATE TRIGGER tsvectorupdate BEFORE INSERT OR UPDATE ON public.posts FOR EACH ROW EXECUTE PROCEDURE public.posts_tsv_trigger();
1198-
1199-
12001204
--
12011205
-- Name: tag_alias FK_38921256eca6f24170411db8ac7; Type: FK CONSTRAINT; Schema: public; Owner: velog
12021206
--

src/env.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ import path from 'path';
44
const { NODE_ENV } = process.env;
55

66
dotenv.config({
7-
path: path.resolve(process.cwd(), NODE_ENV === 'development' ? '.env' : '.env')
7+
path: path.resolve(process.cwd(), NODE_ENV === 'development' ? '.env.development' : '.env')
88
});

src/routes/api/v2/auth/index.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,24 @@ auth.post('/sendmail', async ctx => {
5252
await getRepository(EmailAuth).save(emailAuth);
5353
const emailTemplate = createAuthEmail(!!user, emailAuth.code);
5454

55-
await sendMail({
56-
to: email,
57-
...emailTemplate,
58-
59-
});
55+
try {
56+
if (process.env.NODE_ENV === 'development') {
57+
console.log(
58+
`Login URL: http://${process.env.CLIENT_HOST}/${user ? 'email-login' : 'register'}?code=${
59+
emailAuth.code
60+
}`
61+
);
62+
}
63+
await sendMail({
64+
to: email,
65+
...emailTemplate,
66+
67+
});
68+
} catch (e) {
69+
if (process.env.NODE_ENV !== 'development') {
70+
throw e;
71+
}
72+
}
6073

6174
ctx.body = {
6275
registered: !!user

src/routes/api/v2/auth/social/social.ctrl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ export const socialCallback: Middleware = async ctx => {
395395

396396
const redirectUrl =
397397
process.env.NODE_ENV === 'development'
398-
? 'https://localhost:3000/register?social=1'
398+
? 'http://localhost:3000/register?social=1'
399399
: 'https://velog.io/register?social=1';
400400
ctx.redirect(encodeURI(redirectUrl));
401401
} catch (e) {

0 commit comments

Comments
 (0)