Skip to content

Commit

Permalink
Updated Elide standalone docs to point to main elide.io getting start…
Browse files Browse the repository at this point in the history
…ed docs (#1063)
  • Loading branch information
aklish committed Nov 6, 2019
1 parent 19a9e5a commit 600e442
Showing 1 changed file with 2 additions and 201 deletions.
203 changes: 2 additions & 201 deletions elide-standalone/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,218 +15,19 @@ Table of Contents
The Elide standalone application is a configurable web server using Elide. While Elide is typically a pluggable **middleware** framework, we have constructed a flexible and complete service to allow you to get started quickly.

The Elide standalone application takes an opinionated stance on its technology stack (i.e. jersey/jetty), but provides many opportunities for users to configure the behavior of their application. To use the Elide standalone application, there are only a few steps:
1. Configure ElideStandalone by either implementing the ElideStandaloneSettings interface, or providing basic security configuration.
1. Configure ElideStandalone by implementing the ElideStandaloneSettings interface.
1. Build an uber jar containing `elide-standalone`, your models, security checks, and additional application configuration.
1. Start your web service:
* `$ java -jar YOUR_APP.jar`

To include `elide-standalone` into your project, add the single dependency:
```xml
<dependency>
<groupId>com.yahoo.elide</groupId>
<artifactId>elide-standalone</artifactId>
<version>4.4.1</version>
</dependency>
```

To actually start your Elide application, add the following to your main method:

```java
public class Main {
public static void main(String[] args) throws Exception {
ElideStandalone elide = new ElideStandalone(new ElideStandaloneSettings() {
@Override
public String getModelPackageName() {

//This needs to be changed to the package where your models live.
return "your.model.package";
}

});

elide.start();
}
}
```

## <a name="whofor"></a>Who is this for?

The Elide standalone application is for all new and existing users of Elide. This is the **fastest way to setup an Elide web service** and we have provided several avenues of customization for Elide standalone. However, if you need even more flexibility in your application than what is provided, then you should consider using the Elide __middleware__ directly.

## <a name="gettingstarted"></a>Getting Started

Below we'll walk through a complete example of setting up an Elide service without security.

**If you're interested in seeing a more complete example, check out our [ready-to-run example](https://github.com/DennisMcWherter/elide-example-blog-kotlin).**

### Setup a Database (MySQL)

In our example, we will suggest your create a MySQL database called `elide` that is accessible to the user `elide` with password `elide123`.

### Create the Model

```java
package com.yourcompany.elide.models;

import com.yahoo.elide.annotation.Include;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;

@Entity
@Include(rootLevel = true)
public class Post {
private long id;
private String content;

@Id
public long getId() {
return id;
}

public void setId(long id) {
this.id = id;
}

@Column(nullable = false)
public String getContent() {
return content;
}

public void setContent(String content) {
this.content = content;
}
}
```

### Build the Models Package

An example `pom.xml` for building the model:

```xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.yourcompany.elide</groupId>
<artifactId>example-models</artifactId>
<version>1.0-SNAPSHOT</version>

<dependencies>
<!-- Elide -->
<dependency>
<groupId>com.yahoo.elide</groupId>
<artifactId>elide-standalone</artifactId>
<version>4.4.1</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.yourcompany.elide.app.YourMain</mainClass>
</transformer>
</transformers>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
```

then run:

```
$ mvn clean package
```

### Starting Elide

To start Elide, just run the `start()` method somewhere in your main function:

```java
public class YourMain {
public static void main(String[] args) {
ElideStandalone elide = new ElideStandalone(new ElideStandaloneSettings() {
@Override
public String getModelPackageName() {
//This needs to be changed to the package where your models live.
return "your.model.package";
}
});

elide.start();
}
}
```

### Configure Elide Standalone

While you can provide a user extraction function and checks alone, more advanced configuration is done by implementing the `ElideStandaloneSettings` interface.

### Run Your Service

You can now run your service.

```
$ java -jar YOUR_APP.jar
```

### Query Your Service

#### Create a Post

Run the following curl request:

```
$ curl -X POST \
-H'Content-Type: application/vnd.api+json' \
-H'Accept: application/vnd.api+json' \
--data '{
"data": {
"type": "post",
"id": "0",
"attributes": {
"content": "This is my first post. woot."
}
}
}' \
http://localhost:8080/api/v1/post
```

### Query Your Posts

Run the following curl request:

```
$ curl http://localhost:8080/api/v1/post
```
A complete example of using Elide standalone to setup a simple service can be found [here](https://elide.io/pages/guide/01-start.html).

## <a name="usage"></a>Usage

Expand Down

0 comments on commit 600e442

Please sign in to comment.