This repository has been archived by the owner on Apr 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #93 from couchbaselabs/feature/swagger
Replace HTTP client with SwaggerJS
- Loading branch information
Showing
64 changed files
with
2,698 additions
and
1,474 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"presets": ["react-native"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
[android] | ||
target = Google Inc.:Google APIs:23 | ||
|
||
[maven_repositories] | ||
central = https://repo1.maven.org/maven2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,45 @@ | ||
## ReactNativeCouchbaseLiteExample | ||
## Getting Started | ||
|
||
Example project to get started with the React Native Couchbase Lite module. | ||
1. Open **ios/ReactNativeCouchbaseLiteExample.xcodeproj** in Xcode or **android/build.gradle** in Android Studio. | ||
2. Run `npm install` to install React Native dependencies. | ||
3. Run `npm install ./../` to install react-native-couchbase-lite from the parent directory. | ||
4. Build and run. You should see a list of groceries which is a pre-built database. | ||
|
||
### Getting Started | ||
<img src="https://cl.ly/2t31350o0s3x/Simulator%20Screen%20Shot%2030%20Nov%202016,%2014.08.20.png" width="25%" /> | ||
<img src="https://cl.ly/163J0w0Z2w3q/sdk_phone_x86MASTER11302016140903.png" width="25%" /> | ||
|
||
The instructions below apply to both the iOS and Android versions of the example app. | ||
5. Start Sync Gateway. | ||
|
||
1. Open `ios/ReactNativeCouchbaseLiteExample.xcodeproj` for iOS and `android/build.gradle` for Android. | ||
2. Run `npm install` and `react-native start`. | ||
3. Run the app on a simulator or device. | ||
4. Start Sync Gateway: | ||
```bash | ||
$ ~/Downloads/couchbase-sync-gateway/bin/sync_gateway sync-gateway-config.json | ||
``` | ||
|
||
``` | ||
$ ~/Downloads/couchbase-sync-gateway/bin/sync-gateway sync-gateway-config.json | ||
``` | ||
## Steps to add react-native-couchbase-lite from source | ||
|
||
5. From the current directory, run the following command to import documents. | ||
You may prefer to clone this repo and use it in your project instead of using what is published on npm. The steps below describe how to do that. | ||
|
||
``` | ||
$ curl -H 'Content-Type: application/json' -vX POST 'http://localhost:4984/moviesapp/_bulk_docs' -d @MoviesExample.json | ||
``` | ||
1. Create a new React Native project. | ||
|
||
6. You should now see the list of movies in the iOS app: | ||
```bash | ||
# Update react-native-cli | ||
npm install -g react-native-cli | ||
# Create a new project | ||
react-native init MyApp | ||
# Start the RN server | ||
cd MyApp | ||
react-native start | ||
``` | ||
|
||
<img src="screenshots/thumbnail-ios.png" width="25%" align="left" hspace=30 /> | ||
2. Install the react-native-couchbase-mobile module relatively to the root of this repo. | ||
|
||
<img src="screenshots/thumbnail-android.png" width="25%" /> | ||
```bash | ||
npm install ./../ | ||
``` | ||
|
||
**Note**: On Android, you must open a port mapping with `adb reverse tcp:4984 tcp:4984` to make the Sync Gateway accessible from the Couchbase Listener. | ||
3. Link it with your **MyApp** project. | ||
|
||
```bash | ||
rnpm link react-native-couchbase-lite | ||
``` | ||
|
||
4. Follow [those steps in the README](https://github.com/couchbaselabs/react-native-couchbase-lite#ios) to add the remaining dependencies for iOS and Android. |
12 changes: 12 additions & 0 deletions
12
ReactNativeCouchbaseLiteExample/__tests__/index.android.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import 'react-native'; | ||
import React from 'react'; | ||
import Index from '../index.android.js'; | ||
|
||
// Note: test renderer must be required after react-native. | ||
import renderer from 'react-test-renderer'; | ||
|
||
it('renders correctly', () => { | ||
const tree = renderer.create( | ||
<Index /> | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import 'react-native'; | ||
import React from 'react'; | ||
import Index from '../index.ios.js'; | ||
|
||
// Note: test renderer must be required after react-native. | ||
import renderer from 'react-test-renderer'; | ||
|
||
it('renders correctly', () => { | ||
const tree = renderer.create( | ||
<Index /> | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import re | ||
|
||
# To learn about Buck see [Docs](https://buckbuild.com/). | ||
# To run your application with Buck: | ||
# - install Buck | ||
# - `npm start` - to start the packager | ||
# - `cd android` | ||
# - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"` | ||
# - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck | ||
# - `buck install -r android/app` - compile, install and run application | ||
# | ||
|
||
lib_deps = [] | ||
for jarfile in glob(['libs/*.jar']): | ||
name = 'jars__' + re.sub(r'^.*/([^/]+)\.jar$', r'\1', jarfile) | ||
lib_deps.append(':' + name) | ||
prebuilt_jar( | ||
name = name, | ||
binary_jar = jarfile, | ||
) | ||
|
||
for aarfile in glob(['libs/*.aar']): | ||
name = 'aars__' + re.sub(r'^.*/([^/]+)\.aar$', r'\1', aarfile) | ||
lib_deps.append(':' + name) | ||
android_prebuilt_aar( | ||
name = name, | ||
aar = aarfile, | ||
) | ||
|
||
android_library( | ||
name = 'all-libs', | ||
exported_deps = lib_deps | ||
) | ||
|
||
android_library( | ||
name = 'app-code', | ||
srcs = glob([ | ||
'src/main/java/**/*.java', | ||
]), | ||
deps = [ | ||
':all-libs', | ||
':build_config', | ||
':res', | ||
], | ||
) | ||
|
||
android_build_config( | ||
name = 'build_config', | ||
package = 'com.reactnativecouchbaseliteexample', | ||
) | ||
|
||
android_resource( | ||
name = 'res', | ||
res = 'src/main/res', | ||
package = 'com.reactnativecouchbaseliteexample', | ||
) | ||
|
||
android_binary( | ||
name = 'app', | ||
package_type = 'debug', | ||
manifest = 'src/main/AndroidManifest.xml', | ||
keystore = '//android/keystores:debug', | ||
deps = [ | ||
':app-code', | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.