mariannemyers / slush-marklogic-dotnet

slush generator for an Angular/ASP.NET Core/MarkLogic application
Other
0 stars 0 forks source link

Generator of ASP.NET Core Application Backed by MarkLogic

For 1.1.x support - Use the lts branch of this project. The master branch will be in sync with the latest .NET Core release, currently 2.1.4.

This is a Slush generator that produces a skeleton MarkLogic application with the following components:

Getting Started

Microsoft Windows users should read the additional requirements documentation

Install Required Dependencies

Install the generator

npm install -g slush-marklogic-dotnet (available once published)

If you prefer to use the latest code under development:

npm install -g git://github.com/mariannemyers/slush-marklogic-dotnet.git

If you prefer, install it locally with npm link

cd slush-marklogic-dotnet
sudo npm link

Run the generator

Go to the directory where your new project will be created (the parent). Then:

slush marklogic-dotnet <app-name>

This will ask you several questions, with some intelligent defaults.

Configure your application

Go to the generated application directory:

cd {app-name}

Edit deploy/build.properties to set the -port properties to available ports (defaults: 8040, 8041) and change other properties. The file itself documents many of those properties. Others are described in the documentation for the Roxy deployer. Then run the following Roxy commands to configure your local MarkLogic database (typically, depending on your configuration, it will create a database, associated forest(s), a REST server, an app-user, and a role for that user).

./ml local bootstrap
./ml local deploy modules

On Windows, that would be:

ml.bat local bootstrap
ml.bat local deploy modules

Restore the ASP.NET dependencies

dotnet restore

Run the ASP.NET Core applicaiton

dotnet run

Using Chrome, now visit http://localhost:5000

Next Steps

Load some sample data, as described in the next section of this README.

The slush generation creates an entire project directory, described in Project folder structure.

Explaining the stack gives a more complete description of the overall architecture.

Learn more about specific components of the generated application on the Components page.

Learn about specific ways of customizing your app on the Customization Recipes page.

Data

Sample Data

The application comes with 3000 JSON documents generated by json-generator.com. You can load them with (MLCP)[https://docs.marklogic.com/guide/ingestion/content-pump] like this:

NOTE: @sample-app-role in import-sample-data.options will change to your app's role (Alternatively, you can discover that with ./ml local info)

./ml local mlcp -options_file import-sample-data.options

Or on Windows:

ml.bat local mlcp -options_file import-sample-data.options

General Data Information

The application assumes that you're storing JSON data. This shows up in the default format request for the MLRest service's searchContext, the detailController's (detail-ctrl.js) request to get a document, and in the out-of-the-box detail view.

Options

Roxy

The generator defaults to using a 'rest'-type Roxy app and the 'master' branch of Roxy. If you know what you're doing, and you want to do something different, you can specify those options with this syntax:

slush marklogic-dotnet <appName> appType=mvc branch=dev

Multiple Environments

ASP.NET Core provides support for controlling application behavior across multiple environments, such as development, staging, and production.

ASP.NET Core uses the environment variable ASPNETCORE_ENVIRONMENT to determine which environment the application should run in. This variable can be set to any value, but threee values are used by convention: Development, Staging, and Production.

You can create different appsettings.json configurations for each of your environments by appending the environment name to the filename, for example:

appsettings.Development.json

You can specify the environment by setting the ASPNETCORE_ENVIRONMENT environment variable. The method depends on your operating system. For example, on macOS, the environemtn can be specified in-line:

ASPNETCORE_ENVIRONMENT=Development dotnet run

Refer to "Setting the environment" section here for more details.