반응형
Back4app 서버는 Facebook에서 개발한 Backendless 플랫폼입니다. 해당 플랫폼을 이용하면서 로컬 서버에 사용할 수 있는 가이드도 있어 이번에 설치해보았습니다.
설치 전 주요사항
- Parse-server를 설치하기 위해서는 사전에 Node.js 가 설치해야 하며 DB는 MongoDB 또는 PostgreSQL가 설치 되어 있어야 한다. 여기에서는 MongoDB를 사용함
- 각 프로그램 지원은 홈페이지에 게시되어 있어 각 개발 환경에 맞게 설치하면 됨
- 일반설치와 Docker 설치법이 있지만 여기서는 일반 설치함
사전 설치 항목
- Nodejs
- MongoDB 또는 PostgreSQL
parse-server와 parse-dashboard 설치
1. 설치순서
- parse-server 설치
- parse-dashboard 설치
- cloud code 설치
2. parse-server
npm install -g parse-server mongodb-runner
mongodb-runner start
parse-server --appId APPLICATION_ID --masterKey MASTER_KEY --databaseURI mongodb://localhost/test
3. parse-dashboard
npm install -g parse-dashboard
parse-dashboard --dev --appId yourAppId --masterKey yourMasterKey --serverURL "https://example.com/parse" --appName optionalName
Back4app to local 마이그레이션
# MongoDB 관련 백업 및 복구 명령어 프로그램 설치
sudo apt-get update
sudo apt-get install mongodump mongodump -y
Back4app의 MongoDB Database URI 복사하기
1. 경로 이동
APP 선택 - App Settings - Server Settings - Core Settings - Setting
2. MongoDB Database URI 복사
- MongoDB Database URIMongoDB Database URI 항목에서 내용 복사
- 복사한 내용은 구조는 다음과 같음
#복사한 내용
mongodb://test:test23421@test.back4app.com:27018/45875aasdf48af4
# 구조
mongodb://{계정}:{암호}@{주소}:{포트번호}/{DB명칭}
Local MongoDB에서 Back4app DB 백업하기
- 로컬 컴퓨터에서 복사한 주소를 다음과 같이 구조에 맞게 입력하여 실행
mongodump --out {백업저장할 경로} --host {주소} --port {포트번호} -u {계정} -p {암호} --db {DB명칭}
ex) mongodump --out ./backup --host test.back4app.com --port 27018 -u test -p test23421 --db 45875aasdf48af4
저장한 백업 파일 Local MongoDB에 복원하기
#백업한 데이터가 있는 폴더로 이동
cd /home/user/parse/backup_ctms/8a499e40513540378891b4a7d5059971
mongorestore --host 127.0.0.1 --port 27017 --drop test --db test ./
mongorestore --host {MongoDB주소} --port {포트번호} --db {DB명칭} {백업한 폴더명}
Cloud Code 적용된 parse 서버 설치 방법
- 새프로젝트 생성
- 모듈 설치(express, parse-server)
- 폴더 구조 만들기
- App ID, MasterKey 값 설정하기
Parse Server + express로 적용
const express = require('express');
const ParseServer = require('parse-server').ParseServer;
const app = express();
const server = new ParseServer({
databaseURI: 'mongodb://localhost:27017/dev', // Connection string for your MongoDB database
cloud: './cloud/main.js', // Path to your Cloud Code
appId: 'myAppId',
masterKey: 'myMasterKey', // Keep this key secret!
fileKey: 'optionalFileKey',
serverURL: 'http://localhost:1337/parse' // Don't forget to change to https if needed
});
// Start server
await server.start();
// Serve the Parse API on the /parse URL prefix
app.use('/parse', server.app);
app.listen(1337, function() {
console.log('parse-server-example running on port 1337.');
});
주요링크
# MongoDB 설치 파일
https://www.mongodb.com/try/download/community
# parse-server github
https://github.com/parse-community/parse-server
# parse-dashboard github
https://github.com/parse-community/parse-dashboard
# 마이그레이션
https://www.back4app.com/docs/app-migration/parse-cli-migration
# 로컬에서 클라우드 코드 사용법(Cloud Code Local Debugging)
https://www.back4app.com/docs/local-development/local-debugging
#CLI
https://www.back4app.com/docs/local-development/parse-cli
# 윈도우용 툴
https://www.mongodb.com/try/download/database-tools
#npm 다운받은 폴더
C:\Users\user\AppData\Roaming\npm\node_modules
# power shell 보안오류
https://itpro.tistory.com/100
ExecutionPolicy
Set-ExecutionPolicy Unrestricted 또는
Set-ExecutionPolicy RemoteSigned(추천)
728x90
반응형